<textarea cols='60' rows='8'>This is my statement one.\n This is my statement2</textarea>
<textarea cols='60' rows='8'>This is my statement one.<br/> This is my statement2</textarea>
I tried both but new line is not reflecting while rendering the html file. How can I do that?
just use
<br>
ex:
result:
blablablabla
kakakakakak
fafafafafaf
Try this one:
Line Feed and
Carriage Return are HTML entitieswikipedia. This way you are actually parsing the new line ("\n") rather than displaying it as text.To get a new line inside text-area, put an actual line-break there:
try this.. it works:
replacing for
tags:
If you are talking about using the value of the textarea somewhere else on your page and rendering the newlines, I found the css propperty white-space: pre-wrap; to work very well, and it's a simple solution. Maybe this helps someone.
My
.replace()
function using the patterns described on the other answers did not work. The pattern that worked for my case was: