Reputation:
Have two events:
$('body').mouseup(function(e){}
and
$('.toggle').click(function(e){}
I only want one of these to trigger. I tried
e.stopPropagation(); e.preventDefault(); return false;
but that doesn't seem to stop it. Any ideas? the mouseup is triggered first.
Thanks.
Upvotes: 2
Views: 3961
Reputation: 4788
The problem is they are two different events. If you want to prevent the body.onmouseup, you need to add something on .toggle to catch/stop mouseup events; like
$('.toggle').mouseup(function(e){
e.stopPropagation();
e.preventDefault();
// these two are older ways I like to add to maximize browser compat
e.returnValue = false;
e.cancelBubble = true;
return false;
}
Upvotes: 5