JSFiddle - React, Tailwind, and code Playground

HTML

<div id="container">
    <form id="foo" onsubmit="return false;">
        <button id="target" onclick="console.log(areallyuniquename);">What is my scope?</button>
        <button id="areallyuniquename">I'm a bar</button>
    </form>
</div>
<div id="container2">
</div>

<button onclick="ChangeButtonScope();">Change Scope of Button</button>

<script>
    function ChangeButtonScope() {
    document.getElementById("container2").appendChild(document.getElementById("target"));
    document.getElementById("foo").remove();
}
</script>