javascript - 隐藏没有类和 id 属性的 html 表 2 的第一行

标签 javascript jquery css html-table

我在 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>元素不是 sibling :

$("table").eq(1).find("tr:first").hide();

使用选择器的解决方案 :nth-child(2)仅在第二个 <table> 时有效是其父项的第二个子项,并将选择 every t <table>那是它 parent 的第二个 child 。

关于javascript - 隐藏没有类和 id 属性的 html 表 2 的第一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25350995/

相关文章:

javascript - jQuery show()/hide() 在 iPhone/Android 上工作吗?

javascript - 将 Lottie SVG 居中到标题元素

javascript - 使用 $.grep 过滤数组对象失败

php - 一旦移动到 Media Temple 主机,jQuery(Nvio slider )就不会在 CodeIgniter 应用程序上触发

jquery - 返回一个已经在窗口调整大小之前的元素

css - 悬停时带有图像更改的纯 CSS slider

jquery - 为什么我的 jQuery 不能工作?

javascript - 在 Node.js 的 while 循环内使用 setTimeout

javascript - 为什么悬停不能在 tr 上工作

javascript - 同时旋转和移动图片 Canvas