Javascript 如何使用 jQuery 获取 opener 的元素?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2475649/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 00:31:56  来源:igfitidea点击:

How can I get opener's element with jQuery?

javascriptjquery

提问by Sungguk Lim

Just like in JavaScript:

就像在JavaScript 中一样

opener.document.getElementByName 

jQuery: ??

jQuery: ??

Is there any way to get opener's element with jQuery?

有没有办法openerjQuery获取's element ?

回答by gpmcadam

If I understand you correctly, then you simply pass the opener as the second parameter in the jQuery function, like so:

如果我理解正确,那么您只需将 opener 作为 jQuery 函数中的第二个参数传递,如下所示:

var abc = $("[name=abc]", window.opener.document);

You may also reference the jQuery object directly from the opener, like so:

您也可以直接从 opener 引用 jQuery 对象,如下所示:

var abc = window.opener.jQuery("[name=abc]");

回答by Tom

window.opener.$("[name=elementName]")

Replace elementNamewith the name of your element.

替换elementName为您的元素的名称。