title: JQuery find closest parent tr in nested tr
body: <p>How can I find the parent tr from the closest child tr e.g. from the second child tr, how can I get to the first parent tr?</p>
  
  <p>Below are two table structures I have been using:</p>
  
  <p>1)</p>
  
  <pre><code> &lt;table&gt;
          &lt;tr class="menu"&gt;
              &lt;td&gt;&lt;input type='text' class='parent' value='First Parent'&gt;&lt;/td&gt;  
              &lt;tr class="sub-menu"&gt;
                  &lt;td&gt;&lt;input type='text' class='firstchild' value='First Child'&gt;
                  &lt;/td&gt;
  
              &lt;/tr&gt;
               &lt;tr class="sub-menu"&gt;
                  &lt;td&gt;&lt;input type='text' class='secondchild' value='Second Child'&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;   
          &lt;/tr&gt;
              &lt;tr class="menu" &gt;
              &lt;td &gt;&lt;input type='text' class='parent' value='Second Parent'&gt;&lt;/td&gt; 
              &lt;tr class="sub-menu"&gt;
                  &lt;td&gt;&lt;input type='text' class='firstchild' value='First Child'&gt;
                  &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/tr&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>2)</p>
  
  <pre><code>    &lt;table&gt;
      &lt;tr class="menu"&gt;
          &lt;td&gt;&lt;input type='text' class='parent' value='First Parent'&gt;&lt;/td&gt;  
  &lt;/tr&gt;
          &lt;tr class="sub-menu"&gt;
              &lt;td&gt;&lt;input type='text' class='child' value='First Child'&gt;
              &lt;/td&gt;
        &lt;/tr&gt;
  
           &lt;tr class="sub-menu"&gt;
              &lt;td&gt;&lt;input type='text' class='child' value='Second Child'&gt;
              &lt;/td&gt;
          &lt;/tr&gt;   
      &lt;tr  class="menu"&gt;
  
          &lt;td&gt;&lt;input type='text' class='parent' value='Second Parent'&gt;&lt;/td&gt;  &lt;/tr&gt;
          &lt;tr class="sub-menu"&gt;
              &lt;td&gt;&lt;input type='text' class='child' value='First Child'&gt;
              &lt;/td&gt;
              &lt;/tr&gt;
  
  &lt;/table&gt;
  </code></pre>
  
  <p>I have tried the following JQuery code:</p>
  
  <pre><code>$(this).closest('tr.submenu').closest('tr.menu').find('.parent').val();
  
  $(this).closest('tr.submenu').parent('tr.menu').find('.parent').val();
  
  $(this).closest('tr.menu').find('.parent').val();
  
  $(this).closest('tr.submenu').prevUntil('tr.menu').find('.parent').val();
  
  $(this).closest('tr.submenu').parentsUntil('tr.menu').find('.parent').val();
  
  $(this).closest('tr.submenu').parents(':first-child').find('.parent').val();
  </code></pre>
  
  <p>All attempts have failed. How can I get the parent value from the closest sub menu tr?</p>