title: How to find element count from child to parent with jquery?
body: <p>I have a slight issue where i need to count nest level of elements.
  Problem is that parent element can hold multiple child elements and child elements can have their own child elements.</p>
  
  <p>Please see from where i want to start count (marked with text "I start here").</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div class="main_set"&gt;
      &lt;div class="child_set"&gt;
          &lt;div class="child_set"&gt;
              &lt;div class="child_set"&gt;I start here!&lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="child_set"&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="child_set"&gt;
          &lt;div class="child_set"&gt;&lt;/div&gt;    
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I have tried couple things to get count 3.<br>
  For example my last attempt:</p>
  
  <pre><code>$(this).closest('.main_set').find('.child_set');
  </code></pre>
  
  <p>This one obviously returns 6 tho counting all child_sets.</p>
  
  <p>How to count <code>child_set</code> elements from start place to <code>main_set</code> taking into account only nesting. So basically in my example how to get count 3?</p>