title: tr:last not selecting last row when I add rows with .after in jquery
body: <p>I have some table that looks like so:</p>
  
  <pre><code>&lt;table width="600" border="1" id="mytable"&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td width="300"&gt;col1&lt;/td&gt;
              &lt;td width="100"&gt;col2&lt;/td&gt;
              &lt;td width="100"&gt;col3&lt;/td&gt;
              &lt;td width="100"&gt;col4&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td width="300"&gt;&lt;input type="text"&gt;&lt;/td&gt;
              &lt;td width="100"&gt;&lt;input type="text" size="12"&gt;&lt;/td&gt;
              &lt;td width="100"&gt;&lt;input type="text" size="12"&gt;&lt;/td&gt;
              &lt;td width="100"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td width="300"&gt;&lt;input type="text"&gt;&lt;/td&gt;
              &lt;td width="100"&gt;&lt;input type="text" size="12"&gt;&lt;/td&gt;
              &lt;td width="100"&gt;&lt;input type="text" size="12"&gt;&lt;/td&gt;
              &lt;td width="100"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td width="300"&gt;&lt;input type="text"&gt;&lt;/td&gt;
              &lt;td width="100"&gt;&lt;input type="text" size="12"&gt;&lt;/td&gt;
              &lt;td width="100"&gt;&lt;input type="text" size="12"&gt;&lt;/td&gt;
              &lt;td width="100"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>I then wish to be able to dynamically expand this table by simply checking to see if the last row has any values in it.  If it does, I want to expand it and if it doesn't, I just let it be.  Right now, I'm accomplishing this by listening for a keypress event:</p>
  
  <pre><code>    $("#mytable tr:last input").keypress(function () {
      autoAddRow();
      });
  </code></pre>
  
  <p>which references this:</p>
  
  <pre><code>var _addRow = '&lt;tr&gt;&lt;td width="300"&gt;&lt;input type="text" id="name"&gt;&lt;/td&gt;&lt;td width="100"&gt;&lt;input type="text" size="12" id="units"&gt;&lt;/td&gt;&lt;td width="100"&gt;&lt;input type="text" size="12" id="value"&gt;&lt;/td&gt;&lt;td width="100"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;';
  
  
  function autoAddRow()
  {
      if($('#mytable &gt; tr:last &gt; name').val() != "" || $('#mytable &gt; tr:last &gt; units').val() != ""|| $('#mytable &gt; tr:last &gt; value').val() != "")
      {
          $('#mytable tr:last').after(_addRow);
      }
  }
  </code></pre>
  
  <p>This works, except that when it adds a row, it doesn't treat that like the last row for the purposes of tr:last selection.  In this case, the third row (the last row that is hard-coded) is always what is being checked as the final row in the table.</p>
  
  <p>How can I force it to check the final row of the table as it expands dynamically, or otherwise reproduce this functionality.</p>