Hi guys,
I want to select all the elements that have these two classes 'a' and 'b'. So, only the elements that have both classes. When I use $(".a, .b") it gives me union, but I want intersection.
Hi guys,
I want to select all the elements that have these two classes 'a' and 'b'. So, only the elements that have both classes. When I use $(".a, .b") it gives me union, but I want intersection.
This should work:
$('.a.b')
If you want an intersection, just write the selectors together without spaces in between. So for something that has ID 'a' and classes 'b' and 'c', you'd do:
$('#a.b.c')
You can do this using the filter function:
$(".a").filter(".b")