Chapter 7. Events
As an event-driven programming language, JavaScript does very little on its own; instead, it waits for the user to do something, and then reacts by executing a bit of script.
In order to find out what’s going on in the HTML page, the DOM supports events. Every time the user takes an action—for instance, she clicks on a link, submits a form, loads a new page, changes the value of a form field, or presses a key—an event fires.
You can add event handlers to any elements. Event handlers are functions that are automatically executed when the event takes place on that element. If the script is well thought out, the page responds to user actions and interactivity is born.
All example scripts in this book are event-driven: they kick ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access