title: Making space at the top of a textarea is introducing a syntax error when applying the text generated to a field
body: <p>I am getting a syntax error when reading text back from an xml file. </p>
  
  <p>The data extracted to create the xml was saved in the database after using the following code to add a couple lines in front of a message to allow a reply to typed at the top of a textarea. </p>
  
  <pre><code>$('#message_Text').val(function(index, old) { return '\n\nOriginal Message:\n ' + old ; });
  </code></pre>
  
  <p>This xml created is</p>
  
  <pre><code>&lt;selector&gt;$("#message_Text")&lt;/selector&gt;
  &lt;message&gt;.attr("value","This is a reply Original Message: Hi There")&lt;/message&gt;
  </code></pre>
  
  <p>The console reports</p>
  
  <pre><code>SyntaxError: unterminated string literal
  
  $("#message_Text").attr("value","This is a reply
  </code></pre>
  
  <p>I have tried this with and out the newline \n it makes no difference.</p>
  
  <p>However if I remove the function and just appended a message to the end of the text the syntax error disappears.</p>
  
  <p>So is there something being added to the textarea when attempting to make space at the top of the textarea?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I made a mistake in my original tests I had left the last \n in and this was causing the problem.</p>
  
  <p>So the question I am now seeking to answer is - </p>
  
  <p>I can replace the \n with <br> when writing to the database and this removes the syntax error BUT of course the textarea does not retain it's layout.</p>
  
  <p>Obviously I now see:</p>
  
  <blockquote>
    <p><code>Test with newline stripped.&lt;br/&gt;&lt;br/&gt;Original Message: &lt;br/&gt;Hi There</code></p>
  </blockquote>
  
  <p>I could of course just strip them out completely.</p>
  
  <p>But I really want a method of including them in the XML and retaining the format of the message. .... I think I will attempt to escape the \n perhaps \n and see what happens?</p>