2014-11-24 61 views
0

如何在iframe中的click事件中獲取元素的ID?

<iframe id="myiframe" src="doc.html"> 
    <button id="btn1"></button><!-- how to get this id? --> 
</iframe> 
$('#myiframe').on('click', function() { 
    alert(this.id); 
}); 

我希望它提醒 「BTN1」。

+0

可能重複的[如何選擇使用的document.getElementById內部IFRAME元素(http://stackoverflow.com/questions/14451358/how-to-pick- iframe-using-document-getelementbyid) – 2014-11-24 00:10:21

+2

如果您使用'