如何获取下一个 div 元素及其所有子元素?
<div class="1"></div>
<div class="2">
<div class="child1"></div>
<div class="child2"></div>
</div>
<div class="3">
<div class="child1"></div>
</div>
那么,如果$(this)
当前是第1类,我怎样才能只到达第2类及其所有子类。而且我无法通过类名引用它,因为我不知道那是什么。
我基本上希望将这 2 个语句合并为 1 个。
$(this).next('div').animate({height : 'toggle'});
$(this).next('div *').animate({height : 'toggle'});
最佳答案
$(this).next('div').children().andSelf().animate({height : 'toggle'});
关于jQuery 获取下一个元素及其所有子元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7921557/