Make your website interactive with JavaScript
Difficulty: Beginner ● Progress: 0 / 0 modules completed
React to events
Some HTML elements trigger events. This is the case for <button>, <input>, <textarea> and plenty of other tags!
An event is a mechanism that allows JavaScript to indicate that something has changed on our page. Ex: "this button has been clicked"
To react to an event, two things are needed: listen for the event, and define the action to perform. Let's take this example:
<p>The button has been clicked: <span id="count">0</span> times</p>
<button id="btn">Click!</button>
You need a free account to read this module