If I set the following string into a div how can I get the newline working at HTML?
{
"s":"Phrase1.\n\nPhrase2"
}
Thanks.
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"/>
 
    
    tag.– Ed Marty Jan 03 '11 at 00:17
foo.innerHTML = myObj.s.replace(/\n/g,"<br>");
