View Full Version : jQuery - Change content of an element

01-29-2011, 06:42 PM
I'm trying to change the content of an element from withing an iframe.

If I use this:

then the content of the iframe is replaced correctly.

However when I try to access the parent document it doesn't work. I've been using this code:

$('body', window.parent.document).replaceWith("hi");

What is the correct way to do this? I've tried many tutorials online but nothing seems to be working.

01-29-2011, 07:48 PM
does this help?

01-29-2011, 08:02 PM
Hi no it didn't. I tried using:

$('#menu', window.parent.document).html("hi");

My understanding is that this code would go to the top parent and look for the element with ID 'menu' and would then replace it's contents with "hi".

Is that right?

01-30-2011, 03:35 PM
I guess the iframe behaves differently