Sample code:
<div id="a">
<div id="b">
Click here
</div>
</div>
<script>
$('*').click(function() {
alert($(this).attr('id'));
});
</script>
When you click 'Click Here' it alerts twice, once with 'b' and then with 'a'.
I need to figure out how to get jQuery to ignore all the parents of where the user clicked and just alert, in this case, 'b'.
Try this:
$('*').click(function(e) {
e.stopPropagation();
// do something
});
Here you can find documentation: http://api.jquery.com/event.stopPropagation/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With