title: Access closest child of parent
body: <p>I have an overall 'parent' <code>div</code> with several children. In each child there is 1 or 2 grandchildren.</p>
  
  <p>Say I have a variable holding a child, of the 4<sup>th</sup> child. This is the hierarchy:<code>parent &gt; child4 &gt; secondGrandChild</code>. (View code below for the names.) I then want to access the closest previous <code>secondGrandChild</code> to it.</p>
  
  <p>So basically it should go to <code>child3</code>, check if it has <code>secondGrandChild</code> in it. If it does, great, if not it should go to the previous one and do the same check.</p>
  
  <p>Here's what I tried, but it said it didn't exist:</p>
  
  <pre><code>console.log($('#grandChild4').parent().closest('.chlid &gt; secondGrandChild').offset().left);
  </code></pre>
  
  <p>Here's the hierarchy: (Note, not every child will have <code>secondGrandChild</code>.)</p>
  
  <pre><code>&lt;div class- "parent"&gt;
      &lt;div class="child" id="child1"&gt;
          &lt;div class="firstGrandChild"&gt;&lt;/div&gt;
          &lt;div class="secondGrandChild" id="grandChild1"&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="child" id="child2"&gt;
          &lt;div class="firstGrandChild"&gt;&lt;/div&gt;
          &lt;div class="secondGrandChild" id="grandChild2"&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="child" id="child3"&gt;
          &lt;div class="firstGrandChild"&gt;&lt;/div&gt;
          &lt;!-- &lt;div class="secondGrandChild" id="grandChild3"&gt;&lt;/div&gt; --&gt;
      &lt;/div&gt;
      &lt;div class="child" id="child4"&gt;
          &lt;div class="firstGrandChild"&gt;&lt;/div&gt;
          &lt;div class="secondGrandChild" id="grandChild4"&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="child" id="child5"&gt;
          &lt;div class="firstGrandChild"&gt;&lt;/div&gt;
          &lt;div class="secondGrandChild" id="grandChild5"&gt;&lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>