• 0

jQuery - Change content of an element


Question

I'm trying to change the content of an element from withing an iframe.

If I use this:

$('body').replaceWith("hi");

then the content of a 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?

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

I'm trying to change the content of an element from withing an iframe.

If I use this:

$('body').replaceWith("hi");

then the content of a 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 am not sure about this but there in an error in your code...

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

should be...

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

Link to comment
Share on other sites

  • 0

Can someone please take the time to help me. I've trying to do this for so long now that I'm ready to scrap the whole thing and I don't want to do that.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.