title: How to get top level parent of div
body: <p>I would like to know how to get the top level parent of a div. I know you can use <code>parent()</code>, but I have a click function on multiple divs</p>
  
  <pre><code>&lt;div class="parent" data-row="1"&gt;
    &lt;div class="cat div1"&gt;
      &lt;div class="sub-cat div1_1"&gt;content&lt;/div&gt;
      &lt;div class="sub-cat div1_2"&gt;content&lt;/div&gt;
      &lt;div class="sub-cat div1_3"&gt;
        &lt;div class="inner-cat 1_3_3"&gt;innercontent&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="cat div2"&gt;
      &lt;div class="sub-cat div2_1"&gt;content&lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Let's say I have a parent div, with a parent class name, which also includes an index number in <code>data-row</code>.</p>
  
  <p>I have click functions on the <code>.sub-cat</code>, <code>.inner-cat</code> and <code>.cat</code>, however, I want to get the <code>data-row</code> function with every click.</p>
  
  <p>I've tried retrieving the data-row by using <code>$(this).closest('.parent')</code> to get to the parent div, but that doesn't work as in it returns length <code>0</code>.</p>