HTML:
<div class="parent">
<div class="child"></div>
</div>
jQuery:
$(".parent").on('click', callback);
The problem is that depends on the styling (specifically where the mouse pointer clicks) the click event is fired on .child
or .parent
depending on the location of the mouse.
Is there a way of getting the event always from .parent
even if it was clicked on .child
?
How I used to solve this issue is by checking the id or class of $(event.target)
and if it was not the .parent
then I would do $(event.target).parent()
but I need a solution that works for several scenarios rather than a fix.