title: How can I format text in an HTML <textarea>?
body: <p>I have a <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea" rel="nofollow noreferrer">&lt;textarea&gt;</a> on my page, and when I click a button, the value of the text in the <em>textarea</em> is assigned to <em>.innerHTML</em> of a paragraph on my page.</p>
  <p>Now let's say I type something like this in the <em>textarea</em>:</p>
  <pre class="lang-none prettyprint-override"><code>Hey
  how's
  it
  going
  ?
  </code></pre>
  <p>The paragraph would look like this</p>
  <pre class="lang-none prettyprint-override"><code>Hey how's it going ?
  </code></pre>
  <p>Basically, it wouldn't have <em>&lt;br&gt;</em> tags at the end of each row. Is there a way I can force the JavaScript function to insert <em>&lt;br&gt;</em> tags at the end of each row of my textarea, or is there an easier way to do this?</p>
  <p>JavaScript code:</p>
  <pre><code>document.getElementById(&quot;sendMsgBtn&quot;).onclick = function(){
      var element = document.createElement(&quot;p&quot;);
      element.style.borderBottom = &quot;1px solid black&quot;;
      var content = document.createTextNode(document.getElementById(&quot;currentMsg&quot;).value);
      content = content.replace(/\n/g, &quot;&lt;br&gt;&quot;);
      element.appendChild(content);
      document.body.appendChild(element);
      document.getElementById(&quot;currentMsg&quot;).value = &quot;&quot;;
  }
  </code></pre>