Nodes vs Elements
GiandoDev
Posted on May 7, 2020
image source
In this image above we see our html and the rappresentation of it in the DOM. In the image above all the html is a node and also an element. The element is a special type of node.
This is the list of all types of node not deprecated:
- Element node
- Text node
- Processing instruction node
- Comment node
- Document node
- Document type node
- Document fragment node Nodes have properties and methods; the two most used are Node.parentElement that returns the parent element if it exists, if it does not exist or if it is not an element, returns null. image source
The second is Node.textContent that sets / returns the textual content of an element and all its descendants.
Elements are also nodes but they have also another set of properties and methods that you may use with them. We will see them soon.
💖 💪 🙅 🚩
GiandoDev
Posted on May 7, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.