所以我想点击 img“tri”来隐藏 div“popu”。但是 img 是 div popu 的子项,所以我尝试了 .not()。它没有用。注意:我也不希望 div“textb”触发隐藏。
HTML
<div id="re" class="column"><div id="s" class="popu"><img class="tri" src="img/whtri.png"/>
<div class="textb"><center style="font-size:14px;">Item Title</center>
<span style="font-size:12px;">Description this is an item that is very good and i like it very much! I like
<span class="highl">More...</span>
</span>
<span style="">
</span>
</div>
</div>
JQuery
$("body").click(function (e) {
if (!$(e.target).closest(".popu").length.not(".tri")) {
$("#s").hide(200)
}
});
任何帮助都会很棒!
最佳答案
你可以使用.parent()
:
$('img.tri').click(function() {
$(this).parent().hide();
});
或.closest()
:
$('img.tri').click(function() {
$(this).closest('.popu').hide();
});
关于javascript - jQuery 触发器排除 with .not(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23282461/