buttons in clickable div in jquery

妖精的绣舞 提交于 2019-12-25 02:34:54

问题


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!

How can I disable that ?


回答1:


Use event.stopPropagation() on button click

It will stop the propagatotin to the parent

$("#buttonid").click(function(e){
  e.stopPropagation() 
});


来源:https://stackoverflow.com/questions/22272726/buttons-in-clickable-div-in-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!