JavaScript Curriculum
What is the DOM
easyThe coffee shop HTML and CSS look great. But every time someone wants a menu update, you have to edit the HTML file. The DOM lets JavaScript update the page dynamically — no file edits needed.
What is the DOM
When a browser loads an HTML file, it doesn't just display it — it parses every tag into a tree of JavaScript objects called the Document Object Model (DOM). Each tag becomes a node you can read, modify, and delete with JavaScript.
The DOM Tree
The DOM is a tree. Every element is a node — nested inside its parent, containing its own children. Click nodes below to see how to access each one from JavaScript:
Click any element in the tree to see how to select it with JavaScript.
Node Types
Not everything in the DOM is an element. Text, comments, and the document root itself are all different node types:
<nodetypeexplorer></nodetypeexplorer>
Browser DevTools — Your DOM Playground
DevTools is where you explore, debug, and experiment with the DOM live in the browser:
F12 / Ctrl+Shift+IInspect and edit the live DOM tree. Click any element, see its HTML, edit attributes, add/remove classes in real time. Right-click any element on page → Inspect jumps straight here.
- ›Hover over a node to highlight it on the page
- ›Double-click attribute values to edit them live
- ›Press H to toggle visibility of the selected element
- ›Right-click a node → Break on → subtree modifications to debug DOM changes
// In Console, inspect the selected element:
$0 // currently selected element in Elements panel
$0.style.background = 'red' // live edit
$0.textContent // read text
$0.getAttribute('class')Your Challenge
Open DevTools on any page. In the Console, run: document.querySelector('h1').textContent to read the heading. Then set it: document.querySelector('h1').textContent = 'Hello DOM'. Watch it change live.
Challenge
Open the browser console on any webpage. Use document.querySelector to select the main heading, read its textContent, then change it to something new. Log document.body.children.length to count its direct children.
What is the DOM
easyThe coffee shop HTML and CSS look great. But every time someone wants a menu update, you have to edit the HTML file. The DOM lets JavaScript update the page dynamically — no file edits needed.
What is the DOM
When a browser loads an HTML file, it doesn't just display it — it parses every tag into a tree of JavaScript objects called the Document Object Model (DOM). Each tag becomes a node you can read, modify, and delete with JavaScript.
The DOM Tree
The DOM is a tree. Every element is a node — nested inside its parent, containing its own children. Click nodes below to see how to access each one from JavaScript:
Click any element in the tree to see how to select it with JavaScript.
Node Types
Not everything in the DOM is an element. Text, comments, and the document root itself are all different node types:
<nodetypeexplorer></nodetypeexplorer>
Browser DevTools — Your DOM Playground
DevTools is where you explore, debug, and experiment with the DOM live in the browser:
F12 / Ctrl+Shift+IInspect and edit the live DOM tree. Click any element, see its HTML, edit attributes, add/remove classes in real time. Right-click any element on page → Inspect jumps straight here.
- ›Hover over a node to highlight it on the page
- ›Double-click attribute values to edit them live
- ›Press H to toggle visibility of the selected element
- ›Right-click a node → Break on → subtree modifications to debug DOM changes
// In Console, inspect the selected element:
$0 // currently selected element in Elements panel
$0.style.background = 'red' // live edit
$0.textContent // read text
$0.getAttribute('class')Your Challenge
Open DevTools on any page. In the Console, run: document.querySelector('h1').textContent to read the heading. Then set it: document.querySelector('h1').textContent = 'Hello DOM'. Watch it change live.
Challenge
Open the browser console on any webpage. Use document.querySelector to select the main heading, read its textContent, then change it to something new. Log document.body.children.length to count its direct children.