【发布时间】:2016-11-18 09:13:18
【问题描述】:
我的 .parent() 选择器不适用于 .hide() 函数。 这是我的 HTML:
...
<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)