Is there a way to select a DIV in the parent window using jQuery?
For example:
Main page contains this,
<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.
Something along the logic of,
parent.$("#testdiv").attr("style", content from form);
Use the context-parameter
But if you really use a popup, you need to access opener instead of parent
I came across the same problem but, as stated above, the accepted solution did not work for me.
If you're inside a frame or iframe element, an alternative solution is to use
Here's a quick explanation of the differences between window.opener, window.parent and window.top:
You can also use,
parent.jQuery("#testdiv").attr("style", content from form);
I looked for a solution to this problem, and came across the present page. I implemented the above solution:
But it doesn't work. Maybe it did work in previous jQuery versions, but it doesn't seem to work now.
I found this working solution on another stackoverflow page: how to access parent window object using jquery?
From which I got this working solution:
why not both to be sure?