← JavaScript Essentials

Lesson 3 of 3 · 11 min

Changing the page

The DOM is the live tree of the page. document.querySelector finds an element; textContent changes its text.

addEventListener reacts to clicks: button.addEventListener("click", celebrate).

Practice

Add a button to a page that changes a heading's text when clicked.

Quiz

+50 pts
1. Which finds an element?
2. Clicks are handled with…

Optional resources

Your lesson toolkit

No purchase or partner signup is required to complete this course or earn quiz points.

These are official product links, not active affiliate links. Learnly does not currently earn a commission from them.

Replit

Run your first JavaScript snippets in a browser workspace.

Free and paid plans; usage limits and feature availability vary.

Explore tool

MDN Web Docs

Look up JavaScript and DOM references while you practice.

Free documentation.

Explore tool