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

Selecting Elements by Hierarchy Positioning

$("div span");   //selects <span> elements with a <div> ancestor $("div.menu > span");   //selects <span> elements whose immediate parent   //is a <div> with class="menu" $("label + input.textItem");   //selects <input> elements with class="textItem" that   //are immediately preceded by a <label> $("#menu ~ div");   //selects all <div> elements that are siblings of   //the element with id="menu"

An important set of jQuery selectors is the hierarchy selectors. These selectors allow you to select HTML elements based on the DOM hierarchy. This allows you to write dynamic code that is more content aware by only selecting elements based on parents, children, or other elements ...

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