JSFiddle - React, Tailwind, and code Playground

HTML

<textarea id="inputtext" style="height:100px"></textarea>
<button id="show">show in div</button>
<div id="showtext">
    
</div>

JavaScript

$(function(){
    $('#show').on('click',function(){
        var text = $.trim($('#inputtext').val());
        text = text.replace(/\r?\n/g, "<br />").replace(/<br\s*[\/]?>/gi, "\n");
        $('#showtext').text(text);
    });


});