Is it possible to get all elements with class a or b using getElementsByClassName() only once? I'd prefer vanilla JavaScript.
a
b
getElementsByClassName()
You can't do it with getElementsByClassName() method instead use querySelectorAll() method with comma separated class selectors.
querySelectorAll()
document.querySelectorAll('.a,.b')
1.4m articles
1.4m replys
5 comments
57.0k users