I have some simple tables (multiple, all with class="parent") with multiple <tr>
rows. The <td>
cells within these rows have tables of their own. I'm trying to target the <tr>
rows of the first (parent) tables, like so:
HTML:
<table class="parent">
<tr> <-- match with :first
<td>
<table>
<tr><td></td></tr>
<tr><td></td></tr>
</table>
</td>
</tr>
<tr> <-- match with :last
<td>
<table> <-- so ignore this child ..
<tr><td></td></tr>
<tr><td></td></tr> <-- .. and do NOT match this <tr> with :last
</table>
</td>
</tr>
</table>
jQuery:
$('table.parent').each(function() {
$(this).find('tr:first').dostuff();
$(this).find('tr:last').dostuff();
});
The :first <tr>
works fine, since that's always the <tr>
of the parent. But when I try to select the :last <tr>
, it'll match the last <tr>
of the nested table, and not the last <tr>
of the parent table. How can I tell jQuery to only look at the <tr>
s that are in the parent table, and don't search any further in possible children tables?