WTF is the DOM?

Ian Jones
InstructorIan Jones

Share this video with your friends

Send Tweet
Published 2 years ago
Updated a year ago

The DOM stands for Document Object Model. It is the interface between the JavaScript you write and the browser.

In this lesson, we open up the browser developer console to inspect the HTML within.

Use CMD + OPT + i to open the console quickly.

Instructor: [0:00] The DOM stands for Document Object Model. It is the interface that JavaScript uses to interact with the current HTML page in the browser. If we open our developer tools, and we go to the console, you can access the HTML through the document object.

[0:30] Opening this up, you can see the HTML of this page. In the body, we have a paragraph tag of "peanut butter falcon." To access this paragraph tag directly, we can type document.body.firstElementChild. Now you can see we have a reference to this HTML tag.

[0:57] We can even change it. Document.body.firstElementChild.innerText = "Knives Out." Now you can see that the text of our paragraph tag is "Knives out." If we log out the paragraph, we can see that it's changed.

[1:29] When we reload the page, it goes back to what our actual HTML on our file has displayed.