I'm getting an odd behavior with my "mouseup" event. I have a div inside a div. The mouseup event is attached to the OUTER div, yet if I happen to click on the INNER div, the e.target is set to the child div instead of the parent div that has the event.
Is this normal?
<div class="parent">
<div class="child"></div>
</div>
So a:
$("body").on('mouseup', '.parent',myMethod);
Reports an e.target as child if it's exactly clicked.
Notice the difference between
.target
and.currentTarget
event.target
// A reference to the target to which the event was originally dispatched.event.currentTarget
// A reference to the currently registered target for the event.Worth testing:
Demo jQuery
Demo plain javascript
More reading:
MDN: event.target
MDN: event
jQuery (an explanation about Direct and delegated events)