Events
5 min read
Module Overview
Events
The DOM lets JavaScript read and change a page. Events are how JavaScript finds out something happened: a click, a key press, a form submission. This module covers listening for events and responding to them, including a few behaviors that surprise beginners.
Why This Matters
Nothing on an interactive page happens on its own. A button doesn’t do anything until something is listening for a click on it. Events are the connection between what a user does and what your code does in response.
What You’ll Learn
- Attaching behavior with event listeners
- Mouse, keyboard, and form events
- Event bubbling and capturing: what order events actually fire in
- Event delegation: handling events for elements that don’t exist yet
- Dispatching your own custom events
Outcome
By the end of this module, you’ll be able to make a page respond to a user, and you’ll build a working interactive to-do list to prove it, using nothing but the DOM and events from these two modules.
Let’s get started.