jQuery中可点击div中的按钮 [英] buttons in clickable div in jquery
本文介绍了jQuery中可点击div中的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有整个div,您可以单击以切换该div的主要部分.问题是我在该div中也有可点击的按钮,当我单击它时它会执行应做的操作,但同时也切换了整个div!
I have whole div you can click on which toggles the main part of that div. The problem is I also have clickable button in that div and when I click on it it does what it should but also toggles the whole div at the same time!
如何禁用它?
推荐答案
在按钮点击时使用event.stopPropagation()
这将阻止对父母的宣传素
It will stop the propagatotin to the parent
$("#buttonid").click(function(e){
e.stopPropagation()
});
这篇关于jQuery中可点击div中的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文