父窗口中的jQuery选择元素 [英] jQuery select element in parent window
本文介绍了父窗口中的jQuery选择元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法使用jQuery在父窗口中选择一个DIV?
Is there a way to select a DIV in the parent window using jQuery?
例如:
主页包含这个,
<div id="testdiv"></div>
弹出页面有一个带有一些选项的表单和一个应用"按钮.当用户点击应用时,它会影响主页上的样式属性.
Popup page has a form with some options and an 'Apply' button. When the user clicks apply it affects the style attribute on the main page.
一些符合逻辑的东西,
parent.$("#testdiv").attr("style", content from form);
推荐答案
使用上下文参数
$("#testdiv",parent.document)
但如果你真的使用弹窗,你需要访问 opener 而不是 parent
But if you really use a popup, you need to access opener instead of parent
$("#testdiv",opener.document)
这篇关于父窗口中的jQuery选择元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文