2015-05-14 33 views
1

的第n个孩子我下面的表格有:获取EQ()和表

<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)会得到我想要的行,但是如何获得第thtr,这样我就可以更新UI状态了。

任何帮助表示赞赏。

谢谢。

回答

3

您可以调用链找到的子元素:

$(#'some-table tbody tr').eq(0).find('th').eq(2) 

您也可以在选择使用:eq伪类:

$(#'some-table tbody tr:eq(0) th:eq(2)') 
+0

真棒谢谢。 – NorCalKnockOut