Reputation: 4789
How to select rows in a html table except the table header rows using jquery?
<table id="mytable">
<thead>
<tr>
<th>
Foo
</th>
<td>
Lorem
</td>
<td>
Ipsum
</td>
</tr>
</thead>
<tr>
<th>
Bar
</th>
<td>
Dolor
</td>
<td>
Sit
</td>
</tr>
<tr>
<th>
Baz
</th>
<td>
Amet
</td>
<td>
Consectetuer
</td>
</tr>
</table>
Upvotes: 22
Views: 23248
Reputation: 1373
This selector selects all tr elements in #mytable except the first one (the header).
$('#mytable tr:not(:first)')
Upvotes: 5
Reputation: 382696
You can exclude thead
using not
$('#mytable tr').not('thead tr')
Upvotes: 4
Reputation: 344567
You should wrap the rows in a <tbody>
element (some browsers will do this anyway!), then select the children of that tbody:
$('#mytable > tbody > tr');
Upvotes: 24