jquery子窗体操作父窗体中的元素

1.在父窗口中操作子窗口中的元素,如(其中 iframe1是iframe的ID)
1) 选中IFRAME中的所有单选钮
  $(window.frames["iframe1"].document).find("input[@type='radio']").attr("checked","true");
2).去掉子窗口中类名为top_menu元素的css属性类on
 $(window.frames["iframe1"].document).find('.top_menu').removeClass("on");

2.在IFRAME中操作父窗口的元素
1) 选中父窗口中的所有单选钮
$(window.parent.document).find("input[@type='radio']").attr("checked","true");
2父窗口元素ID为_M1408加上CSS类on
$(window.parent.document).find("#_M1408").addClass("on");

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

好像也可以用$("#myid", top.document);

父窗体调用IFrame中的方法(right)为ifram的id
document.frames["right"].expand();  
父窗体:parent;

子窗体:opener;(window.opener.reload();)

 

$(window.parent.document).find("#alimamaifrm").attr("src","http://www.163.com");

posted @ 2011-05-16 16:54  dodo-yufan  阅读(5767)  评论(1编辑  收藏  举报