使用jQuery定位父窗口 [英] targeting the parent window using jQuery

查看:178
本文介绍了使用jQuery定位父窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我无法解决的示例代码。我是用javascript做的,但是当我使用jQuery时,我无法定位元素。

Here is the sample code which I am not able to solve. I did it using javascript, but when I am doing using jQuery, I do not able to target the element.

脚本:

var element = window.parent.document.getElementById('iframeOne');
//this is working fine      

但是我想用jQuery。那么我该如何定位元素?

But i want to do using jQuery. So how can I target the element?

推荐答案

也许你想做这样的事情

$('#iframeOne', window.parent.document);

另一种方法

window.parent.$("#iframeOne");

另一种方式

$("#iframeOne", top.document);

如果您知道父窗口的名称,您也可以

If you know the name of the parent window, you can also do

$("#iframeOne",opener.document)

这里开启者是窗口的名称。

干杯!!

这篇关于使用jQuery定位父窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆