Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Event.target — the event target

Event.target identifies an event's target, not necessarily the object handling its listener. Learn how it differs from Event.currentTarget.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

event.target

Event.target is read-only: it contains an EventTarget or null. Initially it is null. It belongs to Web APIs, not ECMAScript itself; do not assume the target is a DOM element.

event.currentTarget identifies the object whose listener is currently invoked. Here, the event bubbles from child to parent: its target is child, while the listener runs on parent. This distinction enables event delegation.

Shadow DOM can retarget an event to a tree's host. Thus, target does not always expose the deepest originating node.

Examples

const parent = document.createElement('div');
const child = document.createElement('button');
parent.append(child);

parent.addEventListener('demo', (event) => {
  console.log(event.target === child);
  console.log(event.currentTarget === parent);
});

child.dispatchEvent(new Event('demo', { bubbles: true }));

Result

true
true

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources