-
Notifications
You must be signed in to change notification settings - Fork 22.5k
/
index.md
47 lines (32 loc) · 1.61 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
title: EventTarget
slug: Web/API/EventTarget
page-type: web-api-interface
browser-compat: api.EventTarget
---
{{APIRef("DOM")}}{{AvailableInWorkers}}
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.
{{domxref("Element")}}, and its children, as well as {{domxref("Document")}} and {{domxref("Window")}}, are the most common event targets,
but other objects can be event targets, too.
For example {{domxref("IDBRequest")}}, {{domxref("AudioNode")}}, and {{domxref("AudioContext")}} are also event targets.
Many event targets (including elements, documents, and windows) also support setting [event handlers](/en-US/docs/Web/Events/Event_handlers) via `onevent` properties and attributes.
{{InheritanceDiagram}}
## Constructor
- {{domxref("EventTarget.EventTarget()", "EventTarget()")}}
- : Creates a new `EventTarget` object instance.
## Instance methods
- {{domxref("EventTarget.addEventListener()")}}
- : Registers an event handler of a specific event type on the `EventTarget`.
- {{domxref("EventTarget.removeEventListener()")}}
- : Removes an event listener from the `EventTarget`.
- {{domxref("EventTarget.dispatchEvent()")}}
- : Dispatches an event to this `EventTarget`.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Event reference](/en-US/docs/Web/Events) – the events available in the platform.
- [Introduction to events](/en-US/docs/Learn/JavaScript/Building_blocks/Events)
- {{domxref("Event")}} interface