When I use .bind to bind event on child and parent, child event can stop event propogation with return false; But when I use delegate, return false; does not stop event propagation.
http://jsfiddle.net/J3EAQ/
html:
<div class="parent">
<div class="child"></div>
<div class="child"></div>
</div>
js:
$('.parent').delegate('.child','click',function(e){
alert('child click');
return false;
});
$('.parent').bind('click',function(e){
alert('parent click');
});
e.stopPropagation()
won't work in this case. Use e.stopImmediatePropagation() instead. Here's a fiddle
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