在javascript文本输出中输出换行符?

时间:2013-02-11 19:43:32

标签: jquery html line-breaks

我正在尝试输出由换行符分隔的滚动系列文字信息。

我的代码如下所示:

<script type="text/javascript" src="xbMarquee.js"></script>

<script type="text/javascript">
<!--
//set the marquee parameters
function init() { down_marquee.start(); }
var down_marquee_Text = '<em>"This is a test comment. - Love from Admin /n"This is a far longer test comment which is of greater and more powerful value to the research portions of both physical, mental and citrus flavoured sciences all around the world for years to come."-Love PICKLES"</em>';
var down_marquee_Direction = 'down';
var down_marquee_Contents='<span style="white-space:nowrap;">' + down_marquee_Text + '</span>';
up_marquee = new xbMarquee('down_marquee', '100%', '90%', 6, 100, down_marquee_Direction, 'scroll', down_marquee_Contents);
window.setTimeout( init, 200);
-->
</script></div>

有人可以帮我修复它以便显示换行符吗?我已经尝试了所有我能想到的东西,包括标签等等。

谢谢!

1 个答案:

答案 0 :(得分:0)

使用保留空格的<pre> HTML元素。否则,将\n替换为<br>