6. Traversing the DOM Tree

To paraphrase a line from a famous Christmas story, “Yes, Virginia, we can get there from here—even if there are a lot of steps along the way.”

Selectors are usually fine for identifying elements that you want to work with while using jQuery, but you’ll often find that you need to identify other elements on your pages based on their relationship to the selected elements. These elements might be parents, grandparents, children, or siblings, and the basic concept is that you’re moving up, down, and sideways in the family tree (the DOM) based on which limb you’re currently standing on (the selected elements). This movement is known as

Get jQuery and jQuery UI: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.