title: Get Parent div id in jquery/javascript
body: <p>How can i get Parent Div id of component.</p>
  
  <p>I have already referred this link but its not working.</p>
  
  <p><a href="https://stackoverflow.com/questions/5841650/jquery-get-id-of-element-by-searching-for-it-by-class">jQuery get id of element by searching for it by class</a></p>
  
  <p>Here Is my Sample Code.</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;script src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt;
          &lt;script&gt;
              function linkClickEvent()
              {
                  alert ($(this).parent().attr('id')); //Gives Me Undefined
                  alert($(this).closest('div').attr('id')); //Gives Me Undefined
                  alert($(this).parent().attr('id')); //Gives Me Undefined
              }
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div id="container_1"&gt;
              &lt;a href="#" onclick="linkClickEvent();" id="link_1"&gt;Container_1&lt;/a&gt;
          &lt;/div&gt;
          &lt;div id="container_2"&gt;
              &lt;a href="#" onclick="linkClickEvent();" id="link_2"&gt;Container_2&lt;/a&gt;
          &lt;/div&gt;
          &lt;div id="container_3"&gt;
              &lt;a href="#" onclick="linkClickEvent();" id="link_3"&gt;Container_3&lt;/a&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>