gpt4 book ai didi

jquery - 如何访问tr内表tr

转载 作者:行者123 更新时间:2023-12-01 07:39:30 24 4
gpt4 key购买 nike

我有下面的表格结构

<table class="table-striped table-bordered" style="width: 50%; text-indent: 5px" id="table1">
<thead>
<tr>
<th style="text-align: center; background-color: gray; color: white;" rowSpan="1" colspan="3">HELLO</th>
</tr>
<tr>
<th>#</th>
<th colspan="1">Name</th>
<th style="text-align: right;">Roll</th>
</tr>
</thead>
<tbody ng-repeat="x in x.data.nameList">
<tr>
<td>{{$index+1}}</td>
<td colspan="1">{{x.name}}</td>
<td style="text-align: right;">{{x.position | number:2}}
<a class="glyphicon glyphicon-chevron-down" ng-click=toggle($index) data-toggle="toggle"></a>
</td>
</tr>
<tr id=name{{$index}} class="collapse">
<td colspan="1"></td>
<td colspan="2" style="align-content: right;">
<table class="table table-condensed table-striped" style="width: 100%; text-indent: 5px" ;>

<tr>
<th style="width: 15%; text-align: right;">#</th>
<th nowrap style="width: 20%; text-align: right;">name</th>
<th nowrap style="width: 30%; text-align: right;">class</th>
<th nowrap style="width: 35%; text-align: right;">Position</th>
</tr>
<tr style="text-align: right;" ng-repeat="b in x.positionList">
<td>{{$index+1}}</td>
<td>{{b.idBook}}</td>
<td>{{b.bookName}}</td>
<td>{{b.position | number:2}}</td>
</tr>

</table>
</td>
</tr>
</tbody>

</table>

我想使用 jquery 访问内表 tr,如下所示,

$("#table1>tbody tr:eq(3)").each(function() {

但每次它只返回内表 TR 的单个记录。我期望它将迭代并返回内表 TR 的所有记录/行。您能否建议我任何方法,我该怎么做。

最佳答案

不使用 eq 运算符即可获取#table1 下的所有 tr 元素。

$("#table1>tbody tr").each(function() 

要获取内表的 tr 元素,请使用:

$("#table1>tbody tr>td>table tr").each(function() 

关于jquery - 如何访问tr内表tr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53664260/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com