JSFiddle - React, Tailwind, and code Playground

by tomprogramming

HTML

<div id="content" contenteditable="true">
    
</div>


your div contains:
<div id="log">
    
</div>

CSS

#content {
 border:1px solid #ff0000;   
    min-height:100px;
    min-width:100px;
    margin:20px;
}

#log {
 border: 1px dashed #990000;   
    margin:20px;
    min-height:100px;
}

JavaScript

$("#content").keypress(function(e){
    if (e.which == 13){
        document.execCommand("insertLineBreak");

e.preventDefault();
 e.stopPropagation();       
    }       
        $(this).trigger('change');    
});
    
    
    
    $("#content").bind("change", function(){
        $("#log").text($(this).html())
    })