title: jQuery find highest parent TD
body: <p>I'm working on a code for a form contained within a table. I'm writing (with jQuery) a function to highlight the parent <code>&lt;td&gt;</code> of each <code>&lt;input&gt;</code> element. That part is simple - the code is just:</p>
  
  <pre><code>$('.myForm input').click(function(){
      $(this).parent().addClass('active');
      })
  </code></pre>
  
  <p>The more complicated part is that some text fields are inside of a second table nested within a <code>&lt;td&gt;</code> of the first table. It would look like:</p>
  
  <pre><code>&lt;table&gt;
      &lt;tr&gt;
          &lt;td&gt; &lt;--cell I want to add the class to
              &lt;table&gt;
                  &lt;tr&gt;
                      &lt;td&gt;&lt;input type='text'&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
          &lt;/td&gt;
       &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>So my question is this: is there a way to use one jQuery statement to find the highest parent <code>&lt;td&gt;</code> of the <code>&lt;input&gt;</code> element? So in other words, can I combine:</p>
  
  <pre><code>$('.myForm input').click(function(){
      $(this).parent().addClass('active');
      })
  </code></pre>
  
  <p>and </p>
  
  <pre><code>$('.myForm input').click(function(){
      $(this).parent().parent().addClass('active');
      })
  </code></pre>
  
  <p>into one function?</p>