gpt4 book ai didi

jquery - 如何使用jquery禁用链接内DIV的点击事件?

转载 作者:行者123 更新时间:2023-12-01 06:15:54 26 4
gpt4 key购买 nike

DIV 中有一个链接

<div><a href="#">go</a></div>

我可以禁用 DIV 上的点击事件,但仍可在链接上使用吗?

我用它来测试,但似乎不起作用:

$(this).click(function(event){
var _self_link=$('a',this);
if(event.target!=_self_link){dosomething}
});

有 Jquery 的解决方案吗?谢谢。

最佳答案

我认为你应该使用stopPropagation

Stops the bubbling of an event to parent elements, preventing any parent handlers from being notified of the event.

关于jquery - 如何使用jquery禁用链接内DIV的点击事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8342578/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com