JSFiddle - React, Tailwind, and code Playground

HTML

<div id="someDiv">
    Once upon a midnight dreary
    <br>While I pondered weak and weary
    <br>Over many a quaint and curious
    <br>Volume of forgotten lore.
</div>
Type new text here:<br>
<input type="text" id="replacementtext" />
<input type="button" id="mybutt" value="Swap" />

<input type="hidden" id="vault" />

CSS

#someDiv{width:50%;margin-bottom:30px;background:wheat;}

JavaScript

var savText, newText, myState = 0;

$('#mybutt').click(function(){
    if (myState==0){
        savText = $('#someDiv').html();
        newText = $('#replacementtext').val();
        $('#replacementtext').val(''); //clear field
        $('#someDiv').html( newText );
        myState = 1;
    } else {
        $('#someDiv').html(savText);
        $('#replacementtext').val(newText); //replace contents
        myState = 0;
    }
});