JSFiddle - React, Tailwind, and code Playground

HTML

<div id="frame1" style="border:5px solid black;">
    <iframe src="http://jqueryui.com"></iframe>
</div>
<div id="frame2" style="border:5px solid red;">
</div>
<button id="button1">black</button>
<button id="button2">red</button>

JavaScript

var iframe = $("iframe")[ 0 ];
$("#button1").click( function() {
    document.adoptNode( iframe );
    document.getElementById("frame1").appendChild(iframe);
});
$("#button2").click( function() {
    document.adoptNode( iframe );
    document.getElementById("frame2").appendChild(iframe);
});