- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript DOM
JavaScript DOM
JavaScript DOM
The DOM is the browser's model of a page, and JavaScript uses it to read and change the page.
DOM stands for Document Object Model.
When a page loads, the browser turns your HTML into a tree of objects that JavaScript can reach.
Example
Example
javascript
document.body.innerHTML = '<h1 id="title">Hello</h1>';
const title = document.getElementById("title");
console.log(title.textContent);The output is Hello, read straight out of the page.
What is the DOM?
The DOM is a tree of objects, one for each part of your HTML.
