Say I have this:
<div class="class1 class2"></div>
How do I select this div
element?
document.getElementsByClassName('class1')[0].getElementsByClassName('class2')[0]
That does not work.
I know that, in jQuery, it is $('.class1.class2')
, but I'd like to select it with vanilla JavaScript.
It's actually very similar to jQuery:
document.getElementsByClassName('class1 class2')