文本区域中的新行
问题描述:
<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>
我尝试了两种方法,但是新行在呈现html文件时没有反映出来。
我该怎么做?
I tried both but new line is not reflecting while rendering the html file. How can I do that?
答
试试这个:
Try this one:
<textarea cols='60' rows='8'>This is my statement one. This is my statement2</textarea>
&#10;
换行和&#13;
回车是 HTML实体 wikipedia 。这样你实际上是在解析新行(\\\
)而不是将它显示为文本。
Line Feed and
Carriage Return are HTML entitieswikipedia. This way you are actually parsing the new line ("\n") rather than displaying it as text.