javascript - Pure JS, get element by class but not class -


var items = document.getelementsbyclassname("classname"); 

gives me .classname classes, how update code classes excluding .classname_exclude?

rather using method .getelementsbyclassname(), use method .queryselectorall() (which accepts css3 selectors) , use :not() pseudo class negate elements:

var items = document.queryselectorall('.classname:not(.classname_exclude)'); 

Comments