Ccna final exam - java, php, javascript, ios, cshap all in one. This is a collaboratively edited question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Tuesday, May 29, 2012
jQuery multiple class selector
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.
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:
This should work:
ReplyDelete$('.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:
ReplyDelete$(".a").filter(".b")