title: jQuery - get an input field value from the last row in a table?
body: <p>I'm a little confused on how to do this...  </p>
  
  <p>I have a table that has a series of rows, and within each cell, there are certain form elements.  I'm trying to get the value from the "code" input field from the last row only, and am having trouble with the syntax...  </p>
  
  <p>Simplified table looks like this:</p>
  
  <pre><code>&lt;table id="table1"&gt;
  &lt;tr&gt;&lt;td&gt;&lt;input type="hidden" name="code" value="XFT" /&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;&lt;input type="hidden" name="code" value="ETY" /&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;&lt;input type="hidden" name="code" value="DHQ" /&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>And, here's the jquery that doesn't work... </p>
  
  <pre><code>if($('#cont')) {
              $("#cont').live('click', function(event) {
                  var tr = $('#wr-viewcarttable tr:last');
                  var itemcode = $(tr &gt; 'input[name="code"]').val();
                  window.location = "/search?p="+itemcode;
              });
          }
  </code></pre>