jQuery遍历.next().show())

jQuery遍历.next().show()),jquery,Jquery,在jQuery中进行遍历时遇到问题。。希望这是一个简单的…但我的头撞到了。我已经尝试了.closest(),.next(),.find()。。还有娜达 HTML: .full_项的CSS设置为display:none 目的是在单击span时显示div:full\u项目。更多信息 提前谢谢 .more在p中,它在中。news\u text和中。full\u item是它的兄弟项。因此,以下几点应该可以做到: $(this).closest('.news_text').siblings('.full

在jQuery中进行遍历时遇到问题。。希望这是一个简单的…但我的头撞到了。我已经尝试了
.closest()
.next()
.find()
。。还有娜达

HTML:

.full_项的CSS
设置为
display:none
目的是在单击span
时显示div:full\u项目。更多信息


提前谢谢

.more
p
中,它在
中。news\u text
中。full\u item
是它的兄弟项。因此,以下几点应该可以做到:

$(this).closest('.news_text').siblings('.full_item').show();

span不是.full\u项的同级项。试一试

$(this).parent().nextAll(".full_item").show();
此外,函数
next
将不起作用,因为.full\u项不会紧跟在p的父项之后。改用下一个安装

$(".news_box span.more").click(function(){
   $(this).closest(".news_box").next(".full_item").show();
});

应该有效。

我已将解决方案放入JSFIDLE:


console.log(此)
非常有助于查看正在抓取的内容与您所期望的相比
next
对他的dom不起作用。它不会选择一个元素谢谢你的回复,但这也不是玩球。说得好,我删除了
.next()
,只保留了
.sides()
答案
$(this).parent().next(".full_item").show();
$(this).parent().nextAll(".full_item").show();
$(".news_box span.more").click(function(){
   $(this).closest(".news_box").next(".full_item").show();
});
$(".news_box span.more").click(function(){
    $(this).closest('.news_text').siblings('.full_item').show();
});​