32

Traversing the DOM

In this Chapter

  • Learn how to navigate the DOM tree

  • Use the various APIs you have for moving and re-parenting elements

  • Find an element’s sibling, parent, children, and more

As you may have realized by now, our DOM looks like a giant tree—a giant tree with elements dangerously hanging on to branches and trying to avoid the pointy things that litter the place. To get a little more technical, elements in our DOM are arranged in a hierarchy, as illustrated in Figure 32.1, that defines what we will eventually see in the browser.

images

FIGURE 32.1

The DOM and the browser are like two peas in a pod.

This hierarchy is used to help ...

Get Javascript Absolute Beginner's Guide, 3rd Edition 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.