Seize the opportunity to gain new skills and reshape your career!

Choose a free learning path and get valuable insights from first-rate courses

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 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:

$("h1, h2, h3").click((event) => {
  alert(event.currentTarget.nodeName === "H3");