DOM - Nodes
There is one more kind of manipulation that can be achieved on the DOM tree. We can dynamically add or remove HTML elements. Also, we can access and modify the elements by referring to the relationship of the target HTML element with the element that we already have access to.
According to W3C DOM standard, each HTML element can be referred to as a Node. For example, the entire html document is a 'document node', every other element inside HTML is 'element node'. The content inside these HTML elements is a 'text node'.
Let us see how the Node relationship helps us in Node manipulation.
These nodes appear in hierarchical structure inside the browser. And this hierarchical relationship between the nodes allows us to traverse through the DOM tree.
Let us see DOM API properties that allow us to navigate this tree of nodes:
Property | Description |
---|---|
parentNode | Returns Node object that is parent node of specified node. We can only retrieve this property and cannot set it.
Example: HTML DOM:
|