如何使用 jquery 访问 iFrame 父页面? [英] how to access iFrame parent page using jquery?

查看:33
本文介绍了如何使用 jquery 访问 iFrame 父页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 iframe,为了访问父元素,我实现了以下代码:

I have an iframe and in order to access parent element I implemented following code:

window.parent.document.getElementById('parentPrice').innerHTML

如何使用jquery获得相同的结果?
更新:或者如何使用 jquery 访问 iFrame 父页面?

How to get the same result using jquery?
UPDATE: Or how to access iFrame parent page using jquery?

推荐答案

要在 iFrame 的父级中查找,请使用:

To find in the parent of the iFrame use:

$('#parentPrice', window.parent.document).html();

$() 包装器的第二个参数是要搜索的上下文.这默认为文档.

The second parameter for the $() wrapper is the context in which to search. This defaults to document.

这篇关于如何使用 jquery 访问 iFrame 父页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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