W3cubDocs

/Web APIs

EventTarget

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

* Some parts of this feature may have varying levels of support.

Note: This feature is available in Web Workers.

The EventTarget interface is implemented by objects that can receive events and may have listeners for them. In other words, any target of events implements the three methods associated with this interface.

Element, and its children, as well as Document and Window, are the most common event targets, but other objects can be event targets, too. For example IDBRequest, AudioNode, and AudioContext are also event targets.

Many event targets (including elements, documents, and windows) also support registering event handlers via onevent properties and attributes.

Constructor

EventTarget()

Creates a new EventTarget object instance.

Instance methods

EventTarget.addEventListener()

Registers an event handler of a specific event type on the EventTarget.

EventTarget.removeEventListener()

Removes an event listener from the EventTarget.

EventTarget.dispatchEvent()

Dispatches an event to this EventTarget.

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
EventTarget 64 79 59 51 14 64 59 47 14 9.0 64 14
EventTarget 1 12 1 7
1window.EventTarget did not exist on versions of Safari before 10.1.
18 4 10.1
1window.EventTarget did not exist on versions of Safari iOS before 10.3.
1.0 1
1window.EventTarget did not exist on versions of Safari iOS before 10.3.
addEventListener
1Before Chrome 49, the type and listener parameters were optional.
12 1 7 1
18Before Chrome Android 49, the type and listener parameters were optional.
4 10.1 1
1.0Before Samsung Internet 5.0, the type and listener parameters were optional.
1Before Chrome 49, the type and listener parameters were optional.
1
dispatchEvent 4 12 2 9 3.1 18 4 10.1 3 1.0 4 3
removeEventListener 1 12 1 7 1 18 4 10.1 1 1.0 4.4 1
when 135 135 No 120 No 135 No 89 No No 135 No

See also

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget