我有这段html:
<div id="parent">
<div id="child></div>
</div>
它的图形看起来像这样:
---------------------------
- -
- #parent -
- -
- ---------- -
- - - -
- - #Child - -
- - - -
- ---------- -
- -
---------------------------
如何在 jQuery 中触发一个事件(例如翻转),该事件仅在悬停在 #parent
上时才起作用。但将鼠标悬停在 #child
上时将不起作用
最佳答案
与之类似的问题是jquery stop child triggering parent event
$("#parent").click(function(event){
//do something with parent
});
$("#child").click(function(event){
event.stopPropagation();
});
关于javascript - 如何在 jQuery 中触发父级事件而不是子级事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11226724/