If You have two classes a and b.
<element class="a b">
If you want an intersection, just write the selectors together without spaces in between. So for an element that has an ID of a with classes b and c, you would write:
jQuery('.a.b')
jQuery('#a.b.c')
OR
You can do this using the filter function:
jQuery(".a").filter(".b")
-NOTE: This one will be a little bit slower, because it will build a list of objects with class "a" first, then remove all but those that have class "b", whereas mine does this in one step. But otherwise, no difference.
<element class="a b">
If you want an intersection, just write the selectors together without spaces in between. So for an element that has an ID of a with classes b and c, you would write:
jQuery('.a.b')
jQuery('#a.b.c')
OR
You can do this using the filter function:
jQuery(".a").filter(".b")
-NOTE: This one will be a little bit slower, because it will build a list of objects with class "a" first, then remove all but those that have class "b", whereas mine does this in one step. But otherwise, no difference.
No comments:
Post a Comment