jQuery选择器需要选择父级的所有某些子级 [英] jquery selector needed to select all certain children of parent
问题描述
我的页面上有一些表格.在每个表中,第一行都是正常的,但其余各行都有一类隐藏的,因此在加载时不显示它们.在表格第一行的一个单元格中,有一个链接,单击可单击以查看更多详细信息(淡入该表格的隐藏行).我正在努力使这个工作.因此,基本上,我需要一个选择器,该选择器将查找与单击的元素在同一表中的所有隐藏行,以便可以淡入它们.我使用过:
I have a page with some tables on it. In each table the first row is normal but the rest of the rows have a class of hidden so that they are not displayed on load. In one of the cells on the first row of the table there is a link to click to view more details (fade in the hidden rows of that table). I'm struggling to get this to work though. So basically I need a selector that will find all the hidden rows that are in the same table as the element that's clicked so that they can be faded in. I have used:
$(.hidden).fadeIn()
但是因为页面上有多个表,所以它在所有表的所有隐藏行中消失了,我只想要特定表中的表.我还用过:
but because there is more than one table on the page it fades in all the hidden rows in all of the tables, I just want the ones in the specific table. I also used:
$(this).closest('tr').next(".hidden").fadeIn("slow")
是其中一半的
,但是它仅在该表的第一个隐藏行中消失,但是如果有多个,则其余部分仍被隐藏.任何帮助将非常感激.谢谢
which was half there, but it only fades in the first hidden row in that table but if there's more than one then the rest are still hidden. Any help would be much appreciated. Thanks
推荐答案
尝试-
$(this).closest('tr').nextAll(".hidden").fadeIn("slow");
nextAll的详细文档-
Detailed documentation of nextAll -
http://api.jquery.com/nextAll/
这篇关于jQuery选择器需要选择父级的所有某些子级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!