jQuery - 无法隐藏父级 [英] jQuery - Can't hide parent
本文介绍了jQuery - 无法隐藏父级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我似乎偶然发现了一个非常简单的问题。我试图在点击孩子时隐藏父div。
I've seemed to stumble upon a problem with a very simple task. I'm trying to hide a parent div when the child is clicked.
这是我的HTML;
<div class="wave-wrap"><div class="wave">click me</div></div>
<div class="wave-wrap"><div class="wave">click me</div></div>
<div class="wave-wrap"><div class="wave">click me</div></div>
这是我的jQuery;
Here is my jQuery;
$('.wave').click(function() {
alert($(this).parent().html());
$(this).parent().hide('slow');
});
警告似乎表明我有正确的选择器,但父div拒绝隐藏。有什么想法?
The alert seems to indicate I have the correct selector, yet the parent div refuses to hide. Any ideas why?
推荐答案
尝试 $(this).closest(。wave-wrap)相反.hide()
。
这篇关于jQuery - 无法隐藏父级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文