title: How to find nth parent of an element using jquery
body: <p>I want to find the nth parent element of an given element and access the attributes of parent.</p>
  
  <pre><code>&lt;div id='parent1'&gt;&lt;br/&gt;
    &lt;div id='parent2'&gt;&lt;br/&gt;
         &lt;span&gt;&lt;p id='element1'&gt;Test&lt;/p&gt;&lt;/span&gt;&lt;br/&gt;
    &lt;/div&gt;&lt;br/&gt;
    &lt;div id='parent3'&gt;&lt;br/&gt;
         &lt;span&gt;&lt;p id='element2'&gt;Test&lt;/p&gt;&lt;/span&gt;&lt;br/&gt;
    &lt;/div&gt;&lt;br/&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I want to access the 3rd parent element of element1 without using </p>
  
  <pre><code>$('#element1').parent().parent().parent()
  </code></pre>
  
  <p>Any help would be appreciated</p>