I m breaking a line in javascript using \n for example: -
text = "this is a test" + "\n" + "another test";
and to show that in html i m using the code
text = text.replace('\n' , '<br>');
but the text i m getting is without the br
when check开发者_C百科ing in firebug console i get is with line break(\n not shown but newline created)
how can i place line breaks using \n or i have to do some custom code instead of \n
thanks
var newText = text.replace(/\n/g , "<br>");
use double quotes to not escape the \n
try this:
text = text.replace("\n" , "<br>");
/\r\n|[\r\n]/g <- this is what I use. I am a pessimist..
精彩评论