Loading Depth Study
Preparing your workspace
The DOM is the browser's object representation of the HTML document that JavaScript can read and modify.
When a browser loads HTML, it builds a DOM tree representing the document. JavaScript can use DOM APIs to find elements, change text, update attributes, modify classes, create elements, and remove elements. Common methods include querySelector, querySelectorAll, createElement, and classList operations. Understanding the DOM makes it possible to build interactive web pages without reloading the entire document.
A task application can create a new list item in the DOM whenever the user submits a new task.
const heading = document.querySelector('#heading');
const button = document.querySelector('#changeButton');
button.addEventListener('click', () => {
heading.textContent = 'Learning JavaScript!';
});When the button is clicked, the heading text changes without reloading the page.