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 live online training, plus books, videos, and digital content from nearly 200 publishers.