DOM explorer

Knowledge Videos

Short animated explainers, organised by subject.

DOM explorer

A small page and its DOM tree: click a node to see how JavaScript finds it, and change its text.

The browser turns your HTML into a tree of nodes called the DOM. JavaScript can find a node with document.querySelector and change it, for example with textContent.

The HTML file stays the same when you change the DOM; only the page in the browser changes. Click the nodes of the tree and watch the JavaScript line change.

Things to try

From the videos