jQuery > Traversing methods

.filter() - Filter element from group of similar elements in jQuery

How to filter an element from the group of similar type of elements based on its attribute value in jQuery?


To filter an element from the group of similar kind of elements based on its attribute value, filter() method can be used.

 <script>
      $("p").filter(".class1").css("border", "1px dotted red");
  </script>

Above code snippet will filter the paragraph having class as “class1” and apply css style border 1px style dotted and color red.

 Views: 5217 | Post Order: 43



Write for us






Hosting Recommendations