Using Basic jQuery Filters

Filters Examples

jQuery filters are used to refine the results that are returned from selectors.

A few examples:

  • $("p:first"): of the returned <p> tags, select the first one
  • $("p:even"): select the even-number <p> tags
  • $("a:gt(1)"): of the <a> tags, select all those after the 0th and 1st
  • $("p:not(p:eq(2))"): select all the <p> tags except the one at index 2

This is paragraph 1

This is paragraph 2

This is paragraph 3

This is paragraph 4

This is paragraph 5