john c. j.
john c. j.

Reputation: 1175

Move div into another div, which is located inside iframe

What's the way to move #content into the #wrapper?

index.html

<iframe id="my-iframe" src="./iframe.html"></iframe>
<div id="content"><p>content</p></div>

iframe.html

...
<div id="wrapper"></div>
...

The desired result:

...
<div id="wrapper">
    <div id="content"><p>content</p></div>
</div>
...

Both plain JS and jQuery will be okay, although plain JS is a bit preferably.

Upvotes: 1

Views: 463

Answers (1)

Tyler
Tyler

Reputation: 11509

You can't alter an iframe from a different domain, as that is the purpose of the element (to be unaltered by code on your page).

If you control both pages, you can see here: jQuery/JavaScript: accessing contents of an iframe

Upvotes: 1

Related Questions