【发布时间】:2018-07-19 04:11:51
【问题描述】:
我的桌子是这样的,
<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 上某处找到的解决方案。
这有效,但仅适用于非第一行。在 first 行,发生错误:同一行在第 1 行和 THEAD 标头中都更新。因此,标头row 和 Row 1 具有相同的条目。
所有其他行更新都很好,它们更新正确。
【问题讨论】:
-
<th>关闭不正确。将</th1>更改为</th> -
抱歉,现在更正了 - 我只是在输入以显示 HTML 结构。现在在 OP 中已修复。
标签: javascript jquery html