我有一個在PHP和jQuery中開發的網站。 我有一個圖像在絕對位置的另一個圖像。 小圖片有事件點擊,其父會有另一個事件點擊。但是,當我點擊小圖片上我不想父的事件被觸發 例做: 禁用父母jQuery的點擊事件
如果我的「OK」圖像上單擊父火災事件點擊我有兩個作用,一個來自「好」的形象,另一個來自父母。
我已經在這種模式下嘗試:
$(document).on('click','.social-like',function(event){
//click on "ok" image
event.preventDefault();
});
$(document).on('click','.block-shirt',function(){
//click on rectangle
});
CSS:
.block-shirt{
float:left;
width:133px;
height:170px;
}
.tee{
position:absolute;
top:0;
left:15px;
margin-top:5px;
width:103px;
z-index:5;
}
.social-like{
position:absolute;
bottom:10px;
right:20px;
z-index:10;
width:24px;
height:32px;
}
HTML:
<div class="block-shirt">
<img src="rectangle.png" class="tee"/>
<div class="social-like"></div>
</div>
感謝這工作正常 –