Sunday, January 16, 2011

How to write this in jquery “window.parent.document.getElementById('parentPrice').innerHTML”?

I have an iframe and I wrote this code

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

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

Solution
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.

Courtesy : http://stackoverflow.com/questions/726816/how-to-write-this-in-jquery-window-parent-document-getelementbyidparentprice

1 comment:

  1. It works for me as well...


    $("button", window.parent.document).click(function()
    {
    alert("Functionality defined by def");
    });

    ReplyDelete