Skip to content

Lesson 2 of 4 · 6 min

Buttons and clicks

An event is something that happens, like a click. We can run a function when the event happens.

This counter adds one every time the button is clicked.

Your turn: Make the counter go up by 2 on each click.

Code editor

Live preview