iframe 相关取值问题

<iframe src="iframe.html" id="icontainer" height="0" width="0"></iframe>  

iframe页面
<div id="test">博客园</div>  
JavaScript代码
document.getElementById('icontainer').contentWindow.document.getElementById('test').style.color='red'   
Jquery
$("#icontainer").contents().find("#test").css('color','red');  
其他相关操作 
1. 在父窗口中操作 选中IFRAME#icontainer中的所有单选钮
$(window.frames["icontainer"].document).find("input:radio").attr("checked","true";

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

父窗口想获得IFrame中的Iframe,就再加一个frames子级就行了,如:
$(window.frames["icontainer"].frames["iframe2"].document).find("input:radio").attr("checked","true");
原文地址:https://www.cnblogs.com/szatpig/p/6927224.html