Home

EventTarget

EventTarget is an interface defined by the Web Platform that represents any object to which event listeners can be attached and from which events can be dispatched. It is a foundational element of the DOM event system. In browsers, many core objects implement EventTarget, including Window, Document, and Element instances, as well as several API-specific objects.

The interface provides three primary methods: addEventListener, removeEventListener, and dispatchEvent. addEventListener registers a listener for a

Listeners can be registered with either a boolean capture flag or an options object. The options may

Events flow through a target in three phases: capture, target, and bubble. During capturing, events travel from

In practice, EventTarget provides a unified mechanism for event registration and dispatch across environments, supporting decoupled

given
event
type;
the
listener
can
be
a
function
or
an
object
with
a
handleEvent
method.
removeEventListener
unregisters
a
previously
registered
listener.
dispatchEvent
dispatches
an
Event
to
the
target,
triggering
listeners
whose
types
match
the
event.
include
capture,
once,
passive,
and
signal.
The
once
option
removes
the
listener
after
its
first
invocation.
The
passive
option
indicates
that
the
listener
will
not
call
preventDefault,
enabling
optimization
by
the
browser.
The
signal
option
attaches
an
AbortSignal
to
the
listener,
allowing
automatic
removal
when
the
signal
is
aborted.
the
top-level
ancestors
down
to
the
target;
if
propagation
is
not
stopped,
the
event
then
reaches
the
target
and
may
bubble
up
to
ancestors.
The
event
object
contains
information
such
as
type,
target,
currentTarget,
eventPhase,
bubbles,
cancelable,
and
defaultPrevented.
communication
between
event
producers
and
consumers.