如何使用jquery选择除表表头行之外的html表中的行?
<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>
Run Code Online (Sandbox Code Playgroud)
And*_*y E 23
你应该在一个包中的行<tbody>元素(有些浏览器会做到这一点呢!),然后选择TBODY的孩子:
$('#mytable > tbody > tr');
Run Code Online (Sandbox Code Playgroud)
该选择器选择 #mytable 中除第一个(标题)之外的所有 tr 元素。
$('#mytable tr:not(:first)')
Run Code Online (Sandbox Code Playgroud)