如何在jQuery中撤消event.stopPropagation? [英] How to undo event.stopPropagation in jQuery?

查看:289
本文介绍了如何在jQuery中撤消event.stopPropagation?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用 event.stopPropagation()。然而,出现了一种我希望传播继续的场景,就像上述功能从未被调用一样。所以我想知道是否有一种方法可以在恢复传播之后恢复传播??将一个调用移动到 event.stopPropagation 到十几个单独的条件语句将是非常繁琐的。

I'm using event.stopPropagation() in my application. There has appeared, however, one scenario where I want the propagation to continue as if the aforementioned function was never called. So I'm wondering; is there a way to "resume" propagation after it's been stopped? It would be terribly tedious to move the one call to event.stopPropagation to a dozen separate conditional statements.

推荐答案

一旦传播停止,就无法恢复。
作为解决方法,您可以做的是设置一个变量,然后只有在此变量为true时才停止:

Once propagation has been stopped, it cannot be resumed. As a workaround, what you can do is set a variable, and then only stop if this variable is true:

var stop = false;
// do your logic here
if(stop){
    event.stopPropagation();
}

这篇关于如何在jQuery中撤消event.stopPropagation?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆