title: jquery- store id of clicked link in variable
body: <p>This should be basic, but for some reason its not working for me. I just want to store the id when a link that has a certain class is clicked in a variable so as an example:</p>
  
  <pre><code>&lt;a href="#" id="this_id_here" class="only_this_class"&gt;Some link&lt;/a&gt;
  </code></pre>
  
  <p>I would want jquery to get the id of the link above and store it in a variable. I have tried $this.attr("id") and $this.id, but non of this worked.</p>
  
  <p>This is what I have for the jquery:</p>
  
  <pre><code>  $(".only_this_class").click(function() {
  
        var clickedId= $(this).attr("id");
        alert(clickedId);
     });
  </code></pre>
  
  <p>I just get "undefined" every time.</p>