How can I select an element with multiple classes?
I want to select all the elements that have the two classes
a
and b
.<element class="a b">
So, only the elements that have both classes.
When I use
$(".a, .b")
it gives me the union, but I want the intersection.Answer:
If you want an intersection, just write the selectors together without spaces in between.
$('.a.b')
So for an element that has an ID of
a
with classes b
and c
, you would write:$('#a.b.c')
http://stackoverflow.com/questions/1041344/how-can-i-select-an-element-with-multiple-classes
COMMENTS