jquery 父页面 子页面 同级页面 调用

项目中用到  代码 ,先 展示 ,以便以后用到,直接看下就会明白。

var li_divs = parent.$("#servicelist")[0].contentWindow.$("#ccList .li.div");
li_divs.each(function(){
if($(this).find("a").eq(0).attr("attrid")==$("#id").val()){
$(this).find("a").eq(0).text($("#name").val());
}
});

 

 

以下内容来自转载

主要知识点

1:document.getElementById("ii").contentWindow 得到iframe对象后,就可以通过contentWindow得到iframe包含页面的window对象,然后就可以正常访问页面元素了;

2:$("#ii")[0].contentWindow  如果用jquery选择器获得iframe,需要加一个【0】;

3:$("#ii")[0].contentWindow.$("#dd").val() 可以在得到iframe的window对象后接着使用jquery选择器进行页面操作;

4:$("#ii")[0].contentWindow.hellobaby="dsafdsafsdafsdafsdafsdafsadfsadfsdafsadfdsaffdsaaaaaaaaaaaaa"; 可以通过这种方式向iframe页面传递参数,在iframe页面window.hellobaby就可以获取到值,hellobaby是自定义的变量;

5:在iframe页面通过parent可以获得主页面的window,接着就可以正常访问父亲页面的元素了;

6:parent.$("#ii")[0].contentWindow.ff; 同级iframe页面之间调用,需要先得到父亲的window,然后调用同级的iframe得到window进行操作;

posted @ 2015-01-23 11:38  Struts-pring  阅读(369)  评论(0编辑  收藏  举报