DOM EventTarget Interface
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
| Name | Description |
|---|---|
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
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.
Desktop





Tablets & Mobile





