【问题标题】:Select an element in parent Window from Iframe in an onclick event Jquery在onclick事件Jquery中从Iframe中选择父窗口中的元素
【发布时间】:2017-02-22 07:19:24
【问题描述】:

看看 Iframe 中的这段代码:

$(document).on('click', "#elementfromparentwindow",function (e) {

});

如何在 Iframe 的点击事件中从父窗口中选择元素?

【问题讨论】:

    标签: javascript jquery iframe jquery-selectors


    【解决方案1】:

    应该通过window.parent来完成,如下:

        var parentItem = window.parent.document.getElementById('elementfromparentwindow'); 
    
        $(parentItem).on('click', function(){
    
        });
    

    【讨论】:

      【解决方案2】:

      没关系。刚才搞定了..

      $("#elementfromparentwindow",window.parent.document).on('click',function (e) {
      
      });
      

      【讨论】:

        猜你喜欢
        • 2011-08-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-06-03
        • 2011-10-25
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多