In the following simple HTML, I would like to get all elements with class1 but not with class2.
<li class="class1 class2"></li>
<li class="class1 class3"></li>
<li class="class1 class4"></li>
By using getElementsByClassName('class1')
we could get all elements and then possibly remove elements by checking if a certain class exists.
Is there a better way to do this, without iterating?
I found this interesting post about getting elements with multiple classes, so dare I ask: Is there something like this: document.getElementsByClassName("class1 !class2")
?
P.S.: I don't want to use jQuery.