Methods to filter collections (Become an expert)

We've already delved into filters, but what you probably don't know is that jQuery has methods to filter collections as well. This section describes how many and what are these methods.

Getting ready

The methods of this type are:

Name

Description

eq()

Reduces the retrieved collection to the element having position index+1.

filter()

Reduces the collection to those elements that match the given selector or pass the test function.

first()

Keeps just the first element of the collection.

has()

Reduces the set of matched elements to those that have a descendant that matches the selector or DOM element.

last()

Keeps just the last element of the collection.

map()

Each element of the ...

Get Instant JQuery Selectors 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.