EventTarget

The EventTarget interface is used by objects that can receive events and have listeners set up to handle those events. This interface provides three methods that are implemented by any event target. The most commonly used event targets are element and their children, as well as Document and Window. However, other objects such as XMLHttpRequest, AudioNode, and AudioContext can also be event targets.

In addition to implementing the EventTarget interface, many event targets like elements, documents, and windows also allow setting event handlers through “onevent” properties and attributes.

EventTarget() Creates a new EventTarget object instance.

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.

For more information on EventTarget visit MDN Web Docs.


Contributors