Reputation: 2471
I have a table like this, all rows have the structure like 1st data row
<table id='table1'>
<thead>
<tr>...table headers...</tr>
</thead>
<tr>
<td>xyz</td>
<td>
<table><tr></tr></table>
</td>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
...
...
</table>
All those inside tables have some texts and images.
Initially, I use
$('#table1').find("tr:gt(0)").hide();
to hide everything except header
Now I want to select say from row 1 to row 15 and unhide them. From another post, I know I can use
$('#table1').children('tr').slice(1,15)
to find those rows, but when I want to show them using
$('#table1').children('tr').slice(1,15).show(1000);
all those inside tables are still not showing, but the text "xyz" is showed Am I missing something here?
Upvotes: 1
Views: 104
Reputation: 140228
The tr
are not .children
of table, but descendants because they are inside an implicitly created tbody
element. Try with .children()
of the tbody
$('#table1 > tbody').children().hide();
$('#table1 > tbody').children().slice(1, 15).show(1000);
Upvotes: 1