JSFiddle - React, Tailwind, and code Playground

HTML

<textarea id="myTextArea" placeholder="Type here, then click the button to update the div"></textarea>
<br />

<button id="dohtml">Make HTML</button>
<button id="dotext">Make Text</button>
<button id="dosave">Save Changes</button>
<div id="myDiv"></div>

CSS

#myDiv {
    border:solid 1px #999;
    border-radius:4px;
    min-height:50px;
    margin-top:1em;
    padding:0.5em;
}

#myTextArea {
    min-width:200px;
}

JavaScript

$('#dohtml').click(function() {
    
    var textAreaVal = $('#myTextArea').val();
    
    $('#myDiv').html(textAreaVal);
    
});

$('#dotext').click(function() {
    
    var $div=$('#myDiv'), isEditable=$div.is('.editable');
    $('#myDiv').prop('contenteditable',!isEditable).toggleClass('editable')
    
});

$('#dosave').click(function() {
    
    var test = $('#myDiv').html();
    alert(test);
    $('#myTextArea').val(test);
    
});