liveBook · Manning

addEventListener

addEventListener is a method that registers a callback to be invoked when a specified event is dispatched to an event target.

How 3 Manning books explain it

Vanilla Web

addEventListener is a DOM API method that registers a callback for events of a specified type on an event target.

How it is used
Registers composable handlers for DOM events and lets custom-element consumers receive events through the same API.
How deep it goes
Explains registration, capture and bubble phases, listener options, and removal through small implementations.
Examples
Uses a passive scroll handler, capture and bubble listeners, and a custom rating element’s change event.
What you can do after
Operate/configure it on DOM targets to add, tune, and remove listeners for native and custom events.

Read how Vanilla Web explains addEventListener →

React Quickly, Second Edition

addEventListener is a browser API method that registers a function to be invoked for a specified event on an event target.

How it is used
Registers browser-level handlers for window, document, and referenced DOM nodes outside React’s event properties.
How deep it goes
Explains registration, capture options, propagation phases, React effects, state updates, and unmount cleanup.
Examples
Demonstrates click listeners, capture listeners, referenced DOM nodes, and a React window-resize display.
What you can do after
Operate/configure direct browser listeners, select capture behavior, update React state, and remove handlers during unmount.

Read how React Quickly, Second Edition explains addEventListener →

Secrets of the JavaScript Ninja, Second Edition

A DOM method for registering an event listener on an event target without replacing existing listeners for the same event type.

How it is used
Registers browser event handlers so client-side applications can respond to user actions.
How deep it goes
Defines registration, contrasts property assignment, and demonstrates multiple event types; leaves event-processing flow for later.
Examples
Demonstrates body mousemove and click handlers that append labeled messages to a list.
What you can do after
Apply the DOM method to register multiple handlers for specified events.

Read how Secrets of the JavaScript Ninja, Second Edition explains addEventListener →

Also covered in

What to know first

Related concepts

Questions about addEventListener

What is addEventListener?

addEventListener is a method that registers a callback to be invoked when a specified event is dispatched to an event target.

Which Manning books explain addEventListener?

Vanilla Web, React Quickly, Second Edition and Secrets of the JavaScript Ninja, Second Edition.

What should I know before learning addEventListener?

Manning books that teach addEventListener usually introduce Document Object Model, DOM element and handler first.

What is the difference between addEventListener and on()?

addEventListener is a method that registers a callback to be invoked when a specified event is dispatched to an event target. on() is a D3 selection method that registers an event listener for a specified event type and callback function.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.