JSFiddle - React, Tailwind, and code Playground

HTML

<div class="left">
    <button type="button" class="move">Move</button>
</div>
<div class="right"></div>

CSS

.left, .right {
    display: inline-block;
    border: 1px solid gray;
    width: 200px;
    height: 200px;
    position: absolute;
}

.right {
    left: 220px;
}

JavaScript

$( ".move" ).on( "click", function( event ) {
    var elem = $( this );

    var target = $( this ).closest( ".left" ).length ? ".right" : ".left";
    $( this ).appendTo( target );
});

$( ".right" ).on( "click", "button[type='button']", $.noop );