JSFiddle - React, Tailwind, and code Playground
by SplicePHP
HTML
<div id="esc"></div>
<textarea id="escinput" placeholder="Enter text"></textarea>
JavaScript
$("#escinput").bind("change paste keyup", function () {
$("#esc").text($(this).val().replace(/\n/g, '\\n'));
$("#esc").text($("#esc").html().replace(/"/g, '"'));
});