I have some simple tables 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 (excuse the spacing):

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> <-- ignore this child
        <tr><td></td></tr>
        <tr><td></td></tr> <-- so do NOT match this 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 children tables?

Thanks in advance for your help!

Reply via email to