是否可以从jquery点击事件中排除元素?我的问题的一个简化版本是这样的:用jquery排除元素
CSS
.outerbox{
height:100px;
width:100px;
background-color:red;
position:relative;
}
.innerbox{
height:50px;
width:50px;
background-color:yellow;
margin:auto;
position: absolute;
top: 25%;
left: 25%;
}
HTML
<div class="outerbox">
<div class="innerbox"></div>
</div>
JQUERY
$(".outerbox").not(".innerbox").click(function() {
alert("Red has been clicked, but not the yellow area");
});
我没有选择不工作,虽然。我试过$(“。outerbox:not('。innerbox')”),结果没有任何效果。任何想法我可以做到这一点?
谢谢 - 我想我可以与工作! – JohnG
除非你走了,否则点击它会让你觉得使用点击来获得内部框@JohnG –