无法在jQuery中将点击处理程序附加到iFrame上

时间:2012-05-02 23:34:44

标签: jquery iframe

快速小提琴:http://jsfiddle.net/RP6WD/

代码:

 $('div').click(function(){
    alert('clicked');        
 });

问题是,我在页面上有很多iframe需要附加点击处理程序,所以我无法对.contents().get(0);

做任何事情

1 个答案:

答案 0 :(得分:0)

我有点新手,但有点像this

document.getElementById("<iframe_id>").contentWindow.document.body.onclick = 
function() {
 alert("iframe clicked");
}