有两件事:
$('body').mouseup(function(e){}
和
$('.toggle').click(function(e){}
我只希望其中一个触发。我试过了
e.stopPropagation(); e.preventDefault(); return false;
但这似乎并没有阻止它。有任何想法吗?首先触发mouseup。
感谢。
答案 0 :(得分:4)
问题是它们是两个不同的事件。如果你想阻止body.onmouseup,你需要在.toggle上添加一些内容来捕获/停止mouseup事件;像
$('.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;
}