Wrong Target When Pressing Html Button With Html Tags In It
I have four buttons and want to trace which one is pressed. In some of them I changed innerHTML property with HTML tag. Then I noticed that when a button is pressed there is a poss
Solution 1:
Use currentTarget instead. From MDN:
It always refers to the element the event handler has been attached to as opposed to event.target which identifies the element on which the event occurred
functionclickHandler(me){
console.log(me.currentTarget);
}
Here is a fiddle to demonstrate the above.
Post a Comment for "Wrong Target When Pressing Html Button With Html Tags In It"