WTF is the DOM?

Ian Jones
InstructorIan Jones
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 3 years 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.

egghead
egghead
~ 8 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today