Loading Depth Study
Preparing your workspace
The Document Object Model is a structured representation of a web document exposed to JavaScript.
When the browser parses HTML, it creates a document structure represented as a tree of nodes. JavaScript can use the DOM to find elements, read values, change content, update attributes, add elements, and remove elements. The DOM is not the same thing as the original HTML source; it is the browser's in-memory representation of the current document.
A shopping cart can update the number of items shown on the page by finding a DOM element and changing its text.
<h1 id="title">Hello</h1>
<script>
const title = document.getElementById("title");
title.textContent = "Welcome";
</script>The heading changes from Hello to Welcome.