我有下表:
<table id="some-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>UI Status</th>
<th>Engine Status</th>
</tr>
</thead>
<tbody>
<tr>
<th>A</th>
<th>1</th>
<th></th>
<th></th>
</tr>
<tr>
<th>B</th>
<th>2</th>
<th></th>
<th></th>
</tr>
</tbody>
</table>
我想将 UI 状态插入索引处的表中。
$(#'some-table tbody tr').eq(0)
会得到我想要的行,但我如何得到第 3 个 th
tr
这样我就可以更新 UI 状态。
感谢任何帮助。
谢谢。
最佳答案
您可以链式调用以在元素中查找子元素:
$(#'some-table tbody tr').eq(0).find('th').eq(2)
你也可以在选择器中使用:eq
伪类:
$(#'some-table tbody tr:eq(0) th:eq(2)')
关于javascript - 获取表的 eq( ) 和第 n 个 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30247871/