title: How to get only direct child elements by jQuery function
body: <p>I have a table structure like this:</p>
  
  <pre><code>&lt;table1&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;/td&gt;
          ...
        &lt;td&gt;
          &lt;table2&gt;
            &lt;tbody&gt;
              &lt;tr&gt;
                &lt;td&gt;&lt;/td&gt;
              &lt;/tr&gt;
            &lt;/tbody&gt;
          &lt;/table&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
     &lt;/tbody&gt;
    &lt;/table&gt;
  </code></pre>
  
  <p>In javascript, I have a variable <code>tbl</code> with value of <code>$(table1)</code>, and then I want to get all direct child elements (tr) of <code>&lt;tbody&gt;</code> of <code>table1</code>.
  My code is :</p>
  
  <pre><code>$('tr', tb1)
  </code></pre>
  
  <p>Apparently it returns all <code>&lt;tr&gt;</code> elements in table1 and table2.
  I think I can get by</p>
  
  <pre><code>$('tr', tb1).not(function(){return $(this).parent().parent()[0] != tb1;})
  </code></pre>
  
  <p>or this kind of logic.</p>
  
  <p>I know <code>$('table1 &gt; tbody &gt; tr')</code> can get the direct child <code>tr</code>. Unfortunately I can not use this.</p>
  
  <p>Anyone has good idea about this?</p>
  
  <p>Thanks.</p>