• jquery取得iframe中元素的方法


    原文发布时间为:2010-12-27 —— 来源于本人的百度文章 [由搬家工具导入]

    收集利用Jquery取得iframe中元素的几种方法 :contents()

     $.trim($("iframe").contents().find("p").eq(0).text());

     

    Js代码

    $(document.getElementById('iframeId').contentWindow.document.body).htm()  $(document.getElementById('iframeId').contentWindow.document.body).htm()

     

     显示iframe中body元素的内容。

     

    Js代码 $("#testId", document.frames("iframename").document).html();  $("#testId", document.frames("iframename").document).html();

     根据iframename取得其中ID为"testId"元素

     

    Js代码 $(window.frames["iframeName"].document).find("#testId").html()  $(window.frames["iframeName"].document).find("#testId").html()

     作用同上

     

    收集网上的一些示例:

    用jQuery在IFRAME里取得父窗口的某个元素的值只好用DOM方法与jquery方法结合的方式实现了

    1.在父窗口中操作 选中IFRAME中的所有单选钮
    $(window.frames["iframe1"].document).find("input[@type='radio']").attr("checked","true");

    2.在IFRAME中操作 选中父窗口中的所有单选钮
    $(window.parent.document).find("input[@type='radio']").attr("checked","true");

    iframe框架的:<iframe src="test.html" id="iframe1" width="700" height="300" frameborder="0" scrolling="auto"></iframe>

    IE7中测试通过
  • 相关阅读:
    secFox setting
    Xmind settings lower
    Test435678
    Cmd管理员运行
    office install problems
    MSOCache office问题
    WeRun is mini-app
    解决谷歌跨域调试不可用
    xml文件读写
    c++ 矩阵运算库 Eigen等
  • 原文地址:https://www.cnblogs.com/handboy/p/7163956.html
Copyright © 2020-2023  润新知