Usage of JQuery attribute filters

Filters work with selectors and provide a great control for selecting the elements in DOM. So basically it makes easy our work for selecting elements in DOM.

JQuery filters fall in to six different categories. 
  1. Basic filters
  2. Content filters
  3. Visibility filters
  4. Attribute filters
  5. Child filters
  6. Form filters
In this post is about Attribute filters.



This is a list of usage of JQuery attribute filters.


Filter Purpose
[attribute] Includes elements in the result set if the have the specified attribute
[attribute=value] Includes elements in the result set if the have the specified attribute and it has the given value
[attribute=value] Includes elements in the result set if the have the specified attribute and it doesn't have the given value
[attribute^=value] Includes elements in the result set if the have the specified attribute and it starts with the specified value
[attribute$=value] Includes elements in the result set if the have the specified attribute and it ends with the specified value
[attribute'=value] Includes elements in the result set if the have the specified attribute and it contains the specified value
[attrFilter1][attrFilterN] Includes elements that match all of the specified attribute filters

Practical examples will be demonstrated in this post with details
Feel free to add a comment if you have any question or something to add.

No comments:

Post a Comment