Reputation: 1011
I am having the below table structure
<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>
I want to access the inner table tr using the jquery as below,
$("#table1>tbody tr:eq(3)").each(function() {
But each time its returning me only single record of the inner table TR.I am expecting that it will iterate and will return all the record/row of the inner table TR. Could you please suggest me any approach ,how can i do this.
Upvotes: 1
Views: 109
Reputation: 131
just use this code:
$('table table').on('click',function(){
alert('1');
});
don't forget vote up :)
Upvotes: 0
Reputation: 6944
use without eq operator to get all tr elements under #table1.
$("#table1>tbody tr").each(function()
to get inner table's tr elements use:
$("#table1>tbody tr>td>table tr").each(function()
Upvotes: 3