JSFiddle - React, Tailwind, and code Playground

HTML

<p>
    Once upon a time there was a man
    who lived in a pizza parlor. This
    man just loved pizza and ate it all 
    the time.  He went on to be the
    happiest man in the world.  The end.
</p>
<div id="replace">Replace</div>

JavaScript

$("#replace").click(function() { 
    var p = $("p:first"); 
    alert(p);
    p.replaceWith($("<textarea/>", {
        "class": "edit",
        "text": p.text().replace("\n", "").replace(/\s{2,}/g, " ").trim(),
        "css": {
            "width": p.css('width')
        }
    }));
});