问题
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