O'Reilly logo

Learning jQuery - Fourth Edition by Karl Swedberg, Jonathan Chaffer

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

DOM traversal methods

After creating a jQuery object using $(), we can alter the set of matched elements we are working with by calling one of these DOM traversal methods. DOM traversal methods are discussed in detail in Chapter 2, Selecting Elements.

Filtering

Traversal method

Returns a jQuery object containing…

.filter(selector)

Selected elements that match the given selector.

.filter(callback)

Selected elements for which the callback function returns true.

.eq(index)

The selected element at the given 0-based index.

.first()

The first selected element.

.last()

The final selected element.

.slice(start, [end])

Selected elements in the given range of 0-based indices.

.not(selector)

Selected elements that do not match ...

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