javascript - There is an img tag in a div. Why do I bind events to the div and when printing the clicked object, sometimes it is the img object instead of the div object?
迷茫2017-06-12 09:29:01
0
4
694
When the picture is clicked, the function is also triggered, but I did not bind it to the img. .
Use event.currentTarget, event.target returns the element that triggered the event, and event.currentTarget returns the element that bound the event
Please show how the chooseIcon() method is written.
Because there is an event bubbling mechanism, when you click
img
, the binding event of the parentp
will also be triggered.