JavaScript · Lesson 1 of 4

Make a button change a message

getElementById finds an element by its ID. addEventListener connects a click to your instructions, and textContent changes the displayed text.

Your task

Change the greeting, run the code, then click the button in the result.

Each new lesson builds on your personal page. Your saved lesson draft opens when you return.

The image stays in your browser. Choose it, then use its filename when you add the image to your code.

Edit your project HTML and CSS

Your page

Checks use your current code. Try the page yourself too.

Did your message appear after clicking? Move on to counting clicks.

Next: A counter