I want to select all the elements that have the two classes a and b.
a
b
So, only the e
You can use getElementsByClassName() method for what you want.
getElementsByClassName()
var elems = document.getElementsByClassName("a b c"); elems[0].style.color = "green"; console.log(elems[0]);
a a, b a, b, c
This is the fastest solution also. you can see a benchmark about that here.