![](/img/trans.png)
[英]html nested table hide or show table row by clicking table row first td
[英]Hide first row of html table 2 having no class and no id attributes
我在iframe广告代码中有两个html表,没有class或id属性。 我正在尝试使用jQuery查找第二张表的第一行并将其隐藏? 我的表格如下所示:注意:基本上,我有两个表格,并且两个表格都位于iframe标记内。 我需要隐藏第二张表的第一行吗?
<table>
<tr>
<td> 1 </td>
.
.
.
</tr>
</table>
我需要隐藏下表的第一行:
<table>
<tr>
<td> This row i need to hide() </td>
</tr>
</table>
我也尝试过这样的方式:
$( "table[1] tr:first" ).css("display", "none" );
但没有结果...请帮助。
我建议,假设<table>
元素不是兄弟姐妹:
$("table").eq(1).find("tr:first").hide();
使用选择器:nth-child(2)
解决方案仅在第二个<table>
是其父级的第二个子级时才有效,并将选择每个 t <table>
作为其父级的第二个子级。
调整后的cf注释(jsfiddle也已修改)
看到这个的jsfiddle为$('table').eq(1).find(tr:first').hide();
据我了解(根据OP对@DavidThomas的回答的评论),该表位于iframe
。 您需要先获取该框架的内容,例如
var framebody = $($('iframe')[0].contentDocument.body)
,frameSecondTable = framebody.find('table').eq(1);
jsFiddle显示了它的工作原理。
尝试这个 :
$( "table:nth-child(2) tr:first" ).css("display", "none" );
您可以使用nth-child和jQuery hide
$( "table:nth-child(2) tr:first" ).hide();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.