JSFiddle - React, Tailwind, and code Playground
by piyush saraf
HTML
<div id="myDiv">
This is my text. <br> A new line. <br /> <br> A separated Line.
</div>
<textarea id="myTextArea"></textarea>
JavaScript
jQuery("#myTextArea").val(jQuery("#myDiv").html()
.replace(/\<br\>/g, "\n")
.replace(/\<br \/\>/g, "\n"));jQuery("#myTextArea").val(jQuery("#myDiv").html()
.replace(/\<br\>/g, "\n")
.replace(/\<br \/\>/g, "\n"));