【转载】jquery取得iframe元素的方法

原文地址:http://yaofeng911.iteye.com/blog/552133

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

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

 显示iframe中body元素的内容。

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

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

$(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中测试通过

原文地址:http://yaofeng911.iteye.com/blog/552133

原文地址:https://www.cnblogs.com/ainiaa/p/2007757.html