Intro to the DOM, as told from a student
Today I want to talk about the DOM, otherwise known as the Document Object Model
So what is the DOM?
I’m a visual learner, so one of the first ways I’d explain what the DOM is that it’s a tree. Some of you may have come across trees when you had to find the greatest common factor. For example, 12 is composed of 3 and 4, and 4 branches from 2 multiplied by 2 (see Figure 1)
So I’m sure nodes isn’t widely known especially if you did not come from a coding background. A node represents each point in the tree. Or in the case of our html page, this means that each <img> tag or <div> or even the <!DOCTYPE> element you see at the top of the page is a node.
We can access every node that appears in the browser by using one of the query selector functions such as document.querySelector or document.getElementById.