title: JQuery: Get the parent element id of a clicked element
body: <p>I have a div like this:</p>
  
  <pre><code>&lt;div id="popupDiv1" class="popupDivClass"&gt;
      &lt;a id="popupDivClose" class="popupCloseClass"&gt;x&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>When I click on the 'x' (I want to run a jquery function called <code>disablePopup(id);</code> where id is the id of the coresponding popupDiv (I have many popupDiv each with it's own X button.</p>
  
  <p>in order to do so I implemented the following</p>
  
  <pre><code>$(".popupCloseClass").click(function (event) {
      var buttonID = $(event.target).attr("id");
      var id = $( buttonID).closest("div").attr("id");
  disablePopup(id);
  });
  </code></pre>
  
  <p>basicaly I get the id of the popupCloseClass clicked then I get the id of it's parent (the corresponding popupDiv) via the closest method. then I call disablePopup.</p>
  
  <p>But this is not working.</p>
  
  <p>I even tryed to use the <code>var buttonID = $(buttonID).parent().attr("id");</code> method but did not work either. </p>
  
  <p>I also tried <code>var id = this.id;</code></p>
  
  <p>Any help is greatly appreciated</p>
  
  <p>Thanks</p>