Given an element like
<div class="A B"></div>
where the classes of the div are unknown and/or can change, I want to select elements like
<div class="A"></div>
<div class="B"></div>
<div class="A B"></div>
<div class="B Foo"></div>
in other words any element which has class A or B.
jQuery has the is()
function, so I thought about grabbing the string containing the classes of the main div using attr("class")
, prefixing each class with .
and using is()
to filter, but that feels like a hack. Any way to do this elegantly?