Javascript Get Element Which Handler Was Attached To
When an onclick event is fired on a element how do you get the element the event was attached to from the event object (opposed to the .target element that was clicked on)?
Solution 1:
You could access the currentTarget
property instead.
From MDN :
currentTarget
- Identifies the current target for the event, as the event traverses the DOM. It always refers to the element the event handler has been attached to as opposed toevent.target
which identifies the element on which the event occurred.
Post a Comment for "Javascript Get Element Which Handler Was Attached To"