ILIAS ILIAS - 6 months ago 17
Javascript Question

getElementsByClassName() with two classes

Is it possible to get all classes with name="a" or name="b" by using

getElementsByClassName()
only once?. I'd prefer vanilla Java-script.

Answer

You can't do it with getElementsByClassName() instead use querySelectorAll()

document.querySelectorAll('.a,.b')
Comments