Jquery Attribute Selectors and Filters

Jquery Attribute Selectors and Filters

You can filter the results of a selector based on the it's attributes content. I'malways forgetting these filters so It's handy to have the list someewhere.

Filter Purpose
[attribute] Includes elements in the result set if they have the specified attribute
[attribute=value] Includes elements in the result set if they have the specified attribute and it has the given value
[attribute!=value]

Includes elements in the result set only if they have the specified attribute and it doesn't have the given value

[attribute^=value]

Includes elements that have the specified attribute and it starts with the specified value

[attribute$=value] Includes elements that have the specified attribute and it ends with the specified value
[attribute*=value] Includes elements that have the specified attribute and it contains the specified value
[attrFilter1][attrFilterN] Includes elements that match all of the specified attribute filters

Here are a few examples of how you could use these filters.

comments powered by Disqus