DOM
What is it?
The Document Object Model (DOM) is a programming interface that represents an HTML document as a tree structure where each element, attribute, and piece of text becomes a node. JavaScript can interact with this tree to dynamically read, modify, add, or delete elements on a webpage, enabling interactive and dynamic user experiences without reloading the page.
Practical example
To change the text of a heading when a user clicks a button, you first select the element using document.getElementById or querySelector, then modify its content with element.textContent. You can also change styling with element.style properties, add CSS classes with classList.add, or create entirely new elements using createElement and appendChild methods.
Test your knowledge
What does the DOM represent?