It is unclear if you are looking for equivalent javascript or equivalent jquery (even if the answer is already accepted to make this distinction, if anyone else comes up with this question, they may look for the opposite):
The opposite also applies since you can change jquery to match getElementsByClassName
(rather than change to querySelectorAll
in javascript)
This code:
document.getElementsByClassName('first-class class-child second-child')
returns a massive object of all child elements that have all the specified class names (MDN)
In jquery equivalent:
$('.first-class.class-child.second-child');
which finds all elements that have all the specified class names.
If you want to find elements with any of these class names, use a comma:
$('.first-class,.class-child,.second-child');
source share