【发布时间】:2017-02-22 07:19:24
【问题描述】:
看看 Iframe 中的这段代码:
$(document).on('click', "#elementfromparentwindow",function (e) {
});
如何在 Iframe 的点击事件中从父窗口中选择元素?
【问题讨论】:
标签: javascript jquery iframe jquery-selectors
看看 Iframe 中的这段代码:
$(document).on('click', "#elementfromparentwindow",function (e) {
});
如何在 Iframe 的点击事件中从父窗口中选择元素?
【问题讨论】:
标签: javascript jquery iframe jquery-selectors
应该通过window.parent来完成,如下:
var parentItem = window.parent.document.getElementById('elementfromparentwindow');
$(parentItem).on('click', function(){
});
【讨论】:
没关系。刚才搞定了..
$("#elementfromparentwindow",window.parent.document).on('click',function (e) {
});
【讨论】: