如果一个事件加注,是否有可能阻止其他事件加注?
$(window).click(
function(e)
{
$("#out").html("preventing next event from happening\n");
});
$(window).click(
function(e)
{
$("#out").html($("#out").html() + "evil event should not write here");
});
最佳答案
$(window).click(
function(e)
{
$("#out").html("preventing next event from happening\n");
e.stopImmediatePropagation();
});
$(window).click(
function(e)
{
$("#out").html($("#out").html() + "evil event should not write here");
});
http://api.jquery.com/event.stopImmediatePropagation/ -- 在这里阅读更多内容
关于javascript - 如何防止事件引发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5238797/