CodeAgeBy Sitezack
JavaScript for MakersDOM and events0 XP
Chapter progress0/6

Lesson 3 of 7

React to clicks

addEventListener('click', …) plugs a function into an event: it runs on every click.

That's the heart of interactivity: the user acts, your code answers.

document.getElementById('go').addEventListener('click', function () {
  document.getElementById('status').textContent = 'go!';
});

🎯 Your goal

Add a button id="go" and a paragraph id="status". On click, write exactly go! into the paragraph.

PRO lesson

This advanced chapter is part of CodeAge PRO. Unlock it to keep your adventure going.

Discover PRO