繁体   English   中英

使用'n-child child'更新表中的第n行:第一行出错

[英]Updating n-th Row in Table with 'n-th child': on first row there is an error

我的桌子看起来像这样,

<table>
  <thead>
    <tr>
      <th>Col 1</th>
      <th>Col 2</th>
      <th>Col 3</th>
    </tr>
  </thead>
  <tbody>
    <tr>
       <td>...</td>
       <td>...</td>
       <td>...</td>
    </tr>
    (etc)
  </tbody>
</table>

要使用我的自定义HTML更新第i行(var.rowIndex),我使用jQuery

$("table#tableID  tr:nth-child(" + (rowIndex) + ")").html(html);

'nth-child'是我在StackOverflow上找到的解决方案。

这适用于但不适用于非第1行 第一行,一个错误发生情况: 相同行行1和在THEAD头更新。 因此,标题行和行1都具有相同的条目。

所有其他行更新都很好,它们正确更新。

在选择器中指定tbody

$("tableID tbody tr:nth-child(" + (rowIndex) + ")").html(html);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM