getElementsByClassName() with two classes

You can’t do it with getElementsByClassName() method instead use querySelectorAll() method with comma separated class selectors.

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

Leave a Comment