Favorites

DOM EventTarget Interface

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
EventTarget
DOM InterfaceThis interface is supported by all modern browsers.
Updated 28th November 2026

EventTarget is the interface for any object that can receive events and have listeners, including elements, the document and the window.

Description

The EventTarget interface is implemented by objects that can receive events and have listeners for them. Every element, the document, the window, XMLHttpRequest, AbortSignal and many other objects are event targets.

It has just three methods: addEventListener(), removeEventListener() and dispatchEvent(). You can also create your own event targets with new EventTarget() or by extending the class, which is a simple way to add events to your own objects.

Listeners can be added for the capture phase, as an event travels down from the window to its target, or for the bubble phase, as it travels back up; the default is bubbling. Options such as once, passive and signal control how a listener behaves and how it can be removed. In the DOM, the order of targets an event passes through is determined by the tree, so an event on a button also reaches its parent elements, the document and the window.

Methods

NameDescription
EventTarget.addEventListener()The addEventListener() method runs a function whenever a given event, such as a click or key press, happens on an element, the document or the window.
EventTarget.dispatchEvent()The dispatchEvent() method sends an event to an element or other target, running its listeners straight away.
EventTarget.removeEventListener()The removeEventListener() method removes an event listener that was added with addEventListener(), using the same event type and function.

Example

const bus = new EventTarget();
bus.addEventListener('saved', e => console.log('Saved:', e.detail.id));
bus.dispatchEvent(new CustomEvent('saved', { detail: { id: 7 } }));
console.log(document instanceof EventTarget, window instanceof EventTarget);

Browser Support

The following information will show you the current browser support for the EventTarget interface. Hover over a browser icon to see the version that first introduced support for this interface.

This interface is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee