我的.parent()選擇器不能與.hide()函數一起使用。 這是我的HTML:jQuery .parent()不會觸發隱藏
...
<div class="overpopup">
<div class="overpopup--background">
</div>
<div class="overpopup--content">
<img src="http://placehold.it/600x600?text=Overpopup">
</div>
</div>
...
和我的jQuery的這一部分:
$(document).ready(function() {
...
$('.overpopup--background').click(function(){
$(this).parent().hide();
});
});
任何人都可以發現一個錯誤,我做?我嘗試了不同的動作,如添加CSS工作和那些工作。隱藏父母甚至在jQuery合法嗎?如果沒有,是否有一個簡單的解決方法?
你在想什麼? :D ..刪除自己的父母?哈哈哈.. –
@ParthTrivedi哦對不起,我沒有提到這一點。我試圖隱藏父母。這是一個固定的彈出窗口,背景灰色。我想隱藏整個事情(.overpopup),當一個點擊背景 – Niqql
可能重複的[動態創建的元素的事件綁定?](http://stackoverflow.com/questions/203198/event-binding-on-dynamically -created-elements) –