O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Applying Filters in jQuery Selectors

$("tr:even"); //selects the even <tr> elements $("li:odd"); //selects the odd <li> elements $("div:first"); //selects the first <div> element $("div:last"); //selects the last <div> element $(":header"); //selects <h1>, <h2>, ... elements $("div:eq(5)"); //selects the 6th <div> element $("li:gt(1)"); //selects <div> elements after the first two $("li:lt(2)"); //selects the first two <div> elements $(":animated"); //selects elements currently animating

Often you need to refine your jQuery selectors to a more specific subset. One way to accomplish that is to use filtered selectors. Filtered selectors append a filter on the end of the selector statement that limits the results ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required