title: How to find the nearest parent element attribute value using Jquery
body: <p>I am facing a problem on getting the nearest parent element attribute value using <strong>Jquery</strong>. Can anyone help me on this. My element structure is as below,</p>
  
  <pre><code>&lt;ul class="Someclass"&gt;
  &lt;li&gt;&lt;span id=3 class="heading"&gt;&lt;/span&gt;
    &lt;ul&gt;
      &lt;li&gt;
       &lt;ul&gt; &lt;li&gt;&lt;span &gt;&lt;button onclick= "redirect()"&gt;&lt;/button&gt;&lt;/span&lt;/li&gt;
       &lt;ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;ul&gt;
  
  &lt;script type="text/javascript"&gt;
  function redirect() {
      alert(....)
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>In the above code when i click that element having <code>onclick</code> event i want to get the value as 3 in <code>alert()</code> which is in the element having the class <strong>heading</strong>. The above code is in for loop so it will have more code like this in a same page.</p>