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 ...

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.