使用fromCharCode的HTML换行符不起作用 [英] HTML newline using fromCharCode is not working
本文介绍了使用fromCharCode的HTML换行符不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用String.fromCharCode
在我的html文本中添加新行(或)回车符.
I am using String.fromCharCode
to add new line (or) carriage return to my html text.
就像,
"Ant the other line here..." + String.fromCharCode(13)
Jsfiddle是@ http://jsfiddle.net/udmfsvfn/
Jsfiddle is @http://jsfiddle.net/udmfsvfn/
但是,页面中没有添加换行符!
But, no newline characters are added in the page!!
推荐答案
如果要在HTML中使用换行符,则需要提供<br>
实体而不是换行符(您的String.fromCharCode(13)
代码),因为HTML会解释换行符和文本中的常规空格一样.
If you want a line break in HTML you need to supply <br>
entity instead of a line break (your String.fromCharCode(13)
code) since HTML interprets line breaks as usual spaces in text.
这篇关于使用fromCharCode的HTML换行符不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文