换个新行:不使用\ n [英] Have a new line: not working using \n
本文介绍了换个新行:不使用\ n的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的JS代码中,
In my JS code,
var s1 = 'the 1st line';
var s2 = 'the 2nd line';
var s = s1 + '\n' + s2;
结果是:第一行第二行。
为什么'\ n'不起作用?谢谢。
我尝试了什么:
换新行:不能使用\ n
The result is: the 1st linethe 2nd line.
Why the '\n' does not work? Thanks.
What I have tried:
Have a new line: Not working using \n
推荐答案
因为这是网页,你会使用
Because this is the web you would use
< br />
而不是\ n。
如果结果转到文本文件,请使用\ n
获取新行。
如果结果转到HTML文件,对新行使用< br />
。
If the result goes to a text file, use\n
for new line.
If the result goes to a HTML file, use<br/>
for new line.
这篇关于换个新行:不使用\ n的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文