title: jQuery getting ID of clicked link
body: <p>I have a modal box in jQuery which I have created to display some embed code. <strong>I want the script to take the <code>id</code> of the link that is clicked but I can't seem to get this working.</strong></p>
  
  <p>Does anyone know how I can do that or why this may be happening?</p>
  
  <p>My jQuery code is:</p>
  
  <pre><code>function generateCode() {
      var answerid = $('.openembed').attr('id');
      if($('#embed input[name="comments"]:checked').length &gt; 0 == true) {
          var comments = "&amp;comments=1";
      } else {
          var comments = "";
      }
      $("#embedcode").html('&lt;code&gt;&amp;lt;iframe src="embed.php?answerid=' + answerid + comments + '" width="550" height="' + $('#embed input[name="size"]').val() + '" frameborder="0"&amp;gt;&amp;lt;/iframe&amp;gt;&lt;/code&gt;');
  }
  
  $(document).ready(function () {
      $('.openembed').click(function () {
          generateCode();
          var answerid = $('.openembed').attr('id');
          $('#box').show();
          return false;
      });
      $('#embed').click(function (e) {
          e.stopPropagation()
      });
      $(document).click(function () {
          $('#box').hide()
      });
  });
  </code></pre>
  
  <p>My mark-up is:</p>
  
  <pre><code>&lt;a href="#" id="7830" class="openembed"&gt;Embed&lt;/a&gt;
  &lt;a href="#" id="9999" class="openembed"&gt;Embed&lt;/a&gt;
  </code></pre>