If I set the following string into a div how can I get the newline working at HTML?
{ "s":"Phrase1.\n\nPhrase2" } Thanks.
Wrap preformatted text in <pre> tags:
<pre>{ "s":"Phrase1.\n\nPhrase2" }</pre> Shows up as:
{ "s":"Phrase1. Phrase2" } Edit: Another option would be to set the div's style or class to behave the same as a pre tag:
<div style="whitespace:pre"/> s property of a JSON return value and setting text to that value.white-space not whitespace.foo.innerHTML = myObj.s.replace(/\n/g,"<br>"); \n. If you wrote /\\n/ it would match two ASCII characters, a backslash followed by a letter n.
.replace()method here lampcoder.com/…