O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

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

Getting Siblings That Come After Selected Objects

$("#title").next("p");   //finds the element with id="title" and selects   //the very next <p> element that is a sibling $("p:first").nextAll();   //selects the first <p> element that it finds and   //then selects all the <p> siblings to that element $("p:first").nextUntil("ul");   //selects the first <p> element that it finds and   //then selects all the siblings until it finds a <ul> element

The .next([selector]) method returns a jQuery object representing the next sibling of each element in the current set. If the optional selector is provided, the next sibling is added only if it matches the selector.

The .nextAll([selector]) method returns a jQuery object ...

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