title: Get an element's parent td that is directly below a tr with a certain class
body: <p>I have a complex table structure in a web page as given below. There could potentially be deeper nesting of tables.</p>
  
  <p>I am trying to find a jQuery selector to find the closest td to a given input element, with the added constraint that the tr of this td should have a class of 'class1'.</p>
  
  <p><strong>Question</strong>: How can I get hold of the single 'td` that I have described in above paragraph with the help of jQuery? I have tried some code but unsuccessfully.</p>
  
  <p>For example, if the given input element is <code>firstname</code> then the <code>td</code> immediately surrounding this element would not be one I am looking for, but the td with a comment saying <code>&lt;!--this is the td I am trying to get--&gt;</code> is the correct td.</p>
  
  <p>I have tried following selector to get this td but its returning 6 td DOM elements, when I was expecting only one. You can see this code in action at this url: <a href="http://js.do/sun21170/77256" rel="nofollow">demo for this scenario</a></p>
  
  <p><strong>Code I tried but it doesn't work</strong></p>
  
  <pre><code>$('#firstName').parents("tr.class1").find("td");
  </code></pre>
  
  <p><strong>Html of nested tables</strong></p>
  
  <pre><code>&lt;table&gt;
     &lt;tr class='class1'&gt;
        &lt;td&gt;
           &lt;!--some content here--&gt;
        &lt;/td&gt;
        &lt;td&gt;&lt;!--this is the td I am trying to get--&gt;
           &lt;table&gt;
              &lt;tr&gt;
                 &lt;td&gt;
                    First Name 
                 &lt;/td&gt;
                 &lt;td&gt;
                    &lt;input type='text' id='firstname'&gt;  
                 &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                 &lt;td&gt;
                    Last Name 
                 &lt;/td&gt;
                 &lt;td&gt;
                    &lt;input type='text' id='lastname'&gt;
                 &lt;/td&gt;
              &lt;/tr&gt;
           &lt;/table&gt;
        &lt;/td&gt;
     &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>