🚨 Time is Running Out: Reserve Your Spot in the Lucky Draw & Claim Rewards! START NOW

Code has been added to clipboard!

Use event currentTarget to Return Current Target of Events

Reading time 1 min
Published Dec 29, 2017
Updated Sep 25, 2019

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");
});