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");
});
Latest Coupon Found:
Verified STAFF PICK
TOP-RATED CODING COURSES
Learn the skills of tomorrow
The best time to learn programming is now - follow this link to access 100+ coding courses and enjoy learning at a very low cost!
Expiration date: 22/04/2021
2287 People Used
Only 92 Left