title: How to get containing iframe id when the iframe document is clicked in jquery
body: <p>I am looking for a way to use jQuery to get the id of an iframe when its document element is clicked. The code will be run initialed from the parent window.</p>
  
  <pre><code>$frame = $("&lt;iframe class='frame'&gt;&lt;/iframe&gt;").load(function(){
      $(this).contents().bind("click", function(e){
         alert($(this).attr("id"));
      });
  }
  </code></pre>
  
  <p>the alert reads <strong>undefined</strong>.</p>
  
  <p>Alternatively I also tried:</p>
  
  <p>alert($(this), window.parent).attr("id");</p>