`
mimang2007110
  • 浏览: 232417 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

Jquery操作父级窗口元素

 
阅读更多

有时:window.parent.document 方法获取不到。但是opener.document方法可以。

1) 判断元素是否存在
$("#yourid").length>0 表示id为yourid的元素存在,否则表示不存在;

2) 获取父窗口的元素
$("#yourid", opener.document)
等同于普通写法opener.document.getElementById("yourid").

3)判断父窗口指定元素是否存在
$("#yourid",opener.document).length>0表示存在,否则不存在

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

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

Jquery对父级窗口进行插入行/DOM元素时,insertAfter函数正确用法时:

$("<div>插入的内容</div>",opener.document).insertAfter($("#table1 tr:eq(3)",opener.document));

向父级页面table第三行后插入DIV标签。
 
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics