I've got a nodelist of objects returned by a call to document.getElementsByClassName('a')
. Some of these objects have an extra class b. How can I create an array of elements that contain both classes? I don't was use a global search for b. I prefer vanillaJS/ES6 code.
HTML code example:
<div class ="a"></div>
<div class ="a"></div>
<div class ="a b"></div>
<div class ="a"></div>
<div class ="a b"></div>
<div class ="a"></div>
Try querySelector instead.
document.querySelectorAll('.a.b');
This is likely your simplest solution.