🌐Document Object Model (DOM)
Also known as DOM, DOM Tree, querySelector
The browser's live tree of a page. JavaScript can read it and change it.
Think of it like
Think of it like a family tree for a page. Each part has a parent and kids, and code can move them.
Example
When Lucy adds a mug to her cart, JavaScript finds the cart count in the DOM and changes it from 2 to 3.
Why it matters
Every click that changes a page without reloading it goes through the DOM.
Definition
Example code
javascript
document.querySelector("h1").textContent = "Hi Emma";Common mistake
Key takeaways
- 1A tree of parts. Built from the HTML.
- 2Live. Change it and the page changes.
- 3JavaScript's handle. How code reaches the page.