How can I grab the button element that fires the onClick
event within the handler function? I don't wanna use event.target
as it readily grabs the icon within the button element. Thanks.
Asked
Active
Viewed 50 times
0

moonwalker
- 1,157
- 1
- 18
- 34
-
pass on the reference of button with on click – Shubham Agarwal Bhewanewala Jul 24 '18 at 15:02
-
4`event.currentTarget` will return the element which has the event bound to it as opposed the element clicked. https://www.w3schools.com/jsref/event_currenttarget.asp The issue is not specific to react. https://stackoverflow.com/questions/10086427/what-is-the-exact-difference-between-currenttarget-property-and-target-property/10086501 – Chris Rymer Jul 24 '18 at 15:03
-
Thanks, it works. Not the cleanest way to do it though. – moonwalker Jul 24 '18 at 15:08
-
1This is how to access the node which has the event bound. Maybe make your question more specific if you are trying to solve a particular problem. – Chris Rymer Jul 24 '18 at 15:09