有没有办法停止特定命名空间的传播?

Meg*_*ing 5 javascript jquery

假设我们像这样创建一个事件监听器:

$(element).on("click.namespace",function(e){alert('hi')});
Run Code Online (Sandbox Code Playgroud)

现在我在div上有另一个事件,我想停止第一个事件,保留其他点击事件:

$(element).find('div').on("click",function(e){
    e.stopPropagation(); //I want it to stop only the previous function
});
Run Code Online (Sandbox Code Playgroud)

有没有办法只为这个特定的命名空间停止传播?允许所有其他功能正常运行?

它必须与名称空间相关,因为我要停止的事件是在外部库中

Ano*_*shi 0

是的,您可以使用 not 运算符

$(element+":not(tags to be avoided)").on("click.namespace",function(){
 alert('hi')
});
Run Code Online (Sandbox Code Playgroud)