是否可以從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 –