title: jquery append row onclick
body: <p>**EDIT --- Trying an even more simplified version.... Still doesn't work... Returns $(this).closest is not a function error... **</p>
  
  <pre><code>$("#fitable input[name^=f1]").focus(function() {
          var newRow = '&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;';
          $(this).closest("tbody").append(newRow);
      });
  </code></pre>
  
  <p><strong>Original Post</strong></p>
  
  <p>Pretty new to jQuery, so I'm hoping someone can help me out...  There's a couple of things going on here... Help with any part of it is appreciated.</p>
  
  <p>For starters, I'm trying to append a row to a table when a user clicks in the first enabled input field for that row.   Here's the code I'm trying to use:</p>
  
  <pre><code>    $("#fitable &gt; tbody &gt; tr &gt; td &gt; input").bind('focus', function() {
          if($(this).attr('disabled', false)) {
              $(this).click(function() {
                      var newRow = '&lt;tr&gt;&lt;td&gt;&lt;input name="f1[]" value="" /&gt;&lt;label&gt;CustNew&lt;/label&gt;&lt;/td&gt;&lt;td&gt;&lt;input name="field_n1[]" value="" /&gt;&lt;label&gt;N1&lt;/label&gt;&lt;/td&gt;&lt;td&gt;&lt;input name="field_n2[]" value="" /&gt;&lt;label&gt;N2&lt;/label&gt;&lt;/td&gt;&lt;/tr&gt;';
                      $(this).closest("tbody").append(newRow);
              });
          }
      });
  </code></pre>
  
  <p>If it's helpful, here's the html:</p>
  
  <pre><code>&lt;table id="fitable"&gt;
      &lt;tbody&gt;
          &lt;tr valign="top"&gt;
              &lt;td&gt;&lt;input disabled="disabled" name="cust" id="edit-cust" value="sample@sample.com" type="text"&gt;&lt;label&gt;Cust&lt;/label&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input name="field_n1[]" value="" type="text"&gt;&lt;label&gt;N1&lt;/label&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input name="field_n2[]" value="" type="text"&gt;&lt;label&gt;N2&lt;/label&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>