Use of jQuery attribute filters

Using jQuery attribute filters make it easy to select and modify particular attributes in your html DOM

Use of jQuery attribute filters

Use of jQuery attribute filters

     

Use of jQuery attribute filters

In this section you will learn how to use attribute filters of jQuery.

Using jQuery attribute filters make it easy to select and modify particular attributes in your html DOM. So, you can find the elements based on some query and then modify them to suit your application needs.

Given below is the demonstration how you can apply filters on attribute ,here we are using "a href " attribute of html DOM :

  • Using it , you can hide all the link in your html page as : $("a[href]").toggle();.
  • But if you want to hide one link , you can do it as : $("a[href='http://www.ai.com/']").toggle();
  • If you want to hide the link which has "google" in href.
  • You can also hide the links which ends with "org" as  $("a[href$='org']").toggle();
  • You can also hide the link which starts like " http://doc " as : $("a[href^='http://docs']").toggle();.

Learn from experts! Attend jQuery Training classes.