Skip to content

Commit

Permalink
Add a note describing currentTarget value outside an event handler (m…
Browse files Browse the repository at this point in the history
  • Loading branch information
wbamberg authored May 29, 2024
1 parent 4e947e8 commit e2db3e5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions files/en-us/web/api/event/currenttarget/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The **`currentTarget`** read-only property of the {{domxref("Event")}} interface

This will not always be the same as the element on which the event was fired, because the event may have fired on a descendant of the element with the handler, and then [bubbled](/en-US/docs/Learn/JavaScript/Building_blocks/Events#event_bubbling) up to the element with the handler. The element on which the event was fired is given by {{domxref("Event.target")}}.

Note that the value of `currentTarget` is only available in a handler for the event. Outside an event handler it will be `null`. This means that, for example, if you take a reference to the `Event` object inside an event handler and then access its `currentTarget` property outside the event handler, its value will be `null`.

## Value

An {{domxref("EventTarget")}} representing the object to which the current event handler is attached.
Expand Down

0 comments on commit e2db3e5

Please sign in to comment.