From the course: JavaScript: Enhancing the DOM

Unlock the full course today

Join today to access over 24,000 courses taught by industry experts.

Parent, child, and sibling nodes

Parent, child, and sibling nodes

From the course: JavaScript: Enhancing the DOM

Parent, child, and sibling nodes

- [Instructor] Welcome to the next module. We're going to go on an adventure. (laughs) Maybe I'm overselling it now, but we're going to be traversing the DOM. Traversing the DOM is an essential skill for dynamically navigating through the various elements of your webpage using JavaScript. We've already seen that the DOM is like a tree. So first, let's discuss the family tree of DOM elements, parent, child, and sibling nodes. Every element in a DOM has a place in this family tree. Look, for example, at <body>, the parent node is like the ancestor of an element, in this case, <html>. The child nodes are descendants, and sibling nodes are like its brothers and sisters, in this case, the <head> element. Real life, there's more family members that are very important to us. I've never heard anyone talk about uncles, aunts, cousins, or nieces and nephews in a JavaScript DOM though, but technically, I'm sure you could identify those too. Here you can see the example index.html that I'm going…

Contents