O'Reilly logo

Microsoft Visual Studio 2015 Unleashed, Third Edition by Mike Snell, Lars Powers

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

Traversing Your Selections

As with the DOM, you can traverse jQuery selected results based on child, sibling, or parent nodes. In fact, traversing your jQuery results is nearly the same as the DOM but with a few more methods at your disposal. The methods for traversing jQuery object nodes include .parent(), .parents(), .children(), .siblings(), .next(), and .prev().

As an example, the following shows finding all child nodes of <li> inside the navbar <ul> shown back in Listing 18.1. Recall that this example in the “Document Object Model (DOM)” section of the chapter was more than five lines of code to get this selection.

var sel = $('#navbar').children('li');

Looping Through Your Selection

As you saw previously, ...

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