DOM - Event


This section is about the management of action in the Document object model (ie in the browser)

An event allows for signaling that something has occurred, e.g., that an image has completed downloading.

Event are code structures that listen out for things happening to the document.

In the DOM specification, you can find the following:

  • The concept of a regular event parent and a cross-boundary event parent

The callback function that handle the event can be created with the help of:

  • An event handler. Its name starts with “on” and is followed by the name of the event for which it is intended. (Example: onClick)

and get back an event object


The following features are defined in the DOM Events specification:

  • MouseEvent interface
  • MouseEventInit dictionary type
  • The UIEvent interface's detail attribute

An event's type is synonymous of name type (ie “an event named click” or “if the event name is keypress”)


For example, the following document fragment:

<button class="btn btn-info" onclick="console.log('Bouh!')" >Click Me</button>


In the contexts of events, the terms fire and dispatch are used as defined in the DOM specification:


Event - Fire


Dispatching an event means to follow the steps that propagate the event through the tree.


The term trusted event is used to refer to events whose isTrusted attribute is initialized to true


Event - Missed Event



The type of an event categorize the event. It's also known as the name of the event (Ref)



DOM - Event Type (name)


Event - Category


In the chrome devtool

Devtool Chrome Event Listener

Propagation (Bubble)

An event may bubble (ie propagate) up the dom tree to other subscriber.

Prevent default

If you don't want to have the default behavior (such as following a link), you can prevent it (stop it)


Javascript Event Targets (DOM)


The structure of an event can be found in the Event interface definition.

Create your own

You can also create your own event type. See How to create your own custom event type (Javascript, DOM)?

Documentation / Reference

Task Runner