Jquery 点击事件渗透问题
我有一个 div,它绑定了一个点击事件。我想在该 div 中放置一个图标,该图标有自己的点击事件。当我单击图标时,它会触发图标事件,然后触发 div 的单击事件。如何防止 div 的点击事件触发?
I have a div that has a click event tied to it. I want to put an icon in that div that has it's own click event tied to it. When I click the icon, it fires the icon event and then fires the div's click event. How can I prevent the div's click event from firing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 jQuery 的
event.stopPropagation()
:You can use jQuery's
event.stopPropagation()
:在图标的点击处理程序上停止传播:
Stop the propagation on the icon's click handler: