简体   繁体   English

如何在文本框内将一行文本下推?

[英]How to push a line of text down in a textarea box?

Let's just say I have this function( function() not shown): 只是说我有这个功能( function()未显示):

document.getElementById("chatDisplay").value= document.getElementById("chatDisplay").value + userName + ":" + document.getElementById("textBox").value

what I want to do is between chatDisplay (within) the .value= and the userName is too push that line of code down(similar to a <br> ).Is there anyway to get that done? 我想做的是在chatDisplay.value=之内)和userName之间太往下推那行代码(类似于<br> )。总之有办法做到这一点吗?

Use \\n . 使用\\n It works exactly as <br> but it is used for text. 它与<br>完全一样<br>但是用于文本。 It means new line 这意味着换行

...."chatDisplay").value + "\n" + userName....

Use &#10; 使用&#10; Line Feed and &#13; 换行和&#13; Carriage Return instead of <br/> : 回车代替<br/>

 <textarea cols='60' rows='8'>Hello.&#13;&#10;World&#13;&#10;&#13;&#10;How are you?</textarea> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM