JQUERY,让两个 BIND/Click 一起玩得很好?
我有以下代码行:
<li id="1" class=" ">
<a href="">Parking Lot</a>
<span id="1" class="list-edit">edit</span>
</li>
然后我有两个绑定:
$("#lists li").click(function(){.......
$(".list-edit").click(function(){.........
我遇到的问题是由于 CSS 样式原因,我需要 LI 来包含编辑范围,我有一个大的蓝色背景。但这阻止我绑定编辑按钮。有什么办法可以让两个人玩得愉快吗?
谢谢
I have the following line of code:
<li id="1" class=" ">
<a href="">Parking Lot</a>
<span id="1" class="list-edit">edit</span>
</li>
I then have two binds:
$("#lists li").click(function(){.......
$(".list-edit").click(function(){.........
The problem I'm having is I need the LI to contain the EDIT span because of CSS styling reasons, I have a big blue background. But this is preventing me from binding the EDIT btn. Is there a way to get these two to play nice?
Thxs
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
event.stopPropagation
来阻止附加的点击处理程序单击编辑范围时触发到父 LI(如果这就是您的意思):You can use
event.stopPropagation
to prevent the click handler attached to the parent LI from firing when the edit span is clicked (if that's what you mean):