jQuery event currentTarget: Main Tips
- After traversing the DOM, jQuery event currentTarget property specifies the element to which an event is applied.
- This method is the opposite of event.target since it returns the element that had the event handler assigned.
What Does currentTarget Represent
The jQuery currentTarget has the same purpose as this selector. It returns the current target (DOM element) for the event.
In the code example below, an alert message is set to only return True if the jQuery event currentTarget matches this
, or when <h3>
is clicked:
Example
$("h1, h2, h3").click((event) => {
alert(event.currentTarget.nodeName === "H3");
});