javascript return new line

拥有回忆 提交于 2019-12-25 12:07:32

问题


Simple question, I'm trying to output some text using javascript, and I want to have a new line between some of my text. The following code is what I'm using currently:

{
                text: '1/2 + 1/2',
                value: '[one_half]...[/one_half]\n[one_half]...[/one_half]',
                onclick: function() {
                    editor.insertContent(this.value());
                },

And this outputs

[one_half]...[/one_half] [one_half]...[/one_half]

how do I make it so my outputted text is:

[one_half]...[/one_half]
[one_half]...[/one_half]

回答1:


use <br/> instead of \n..




回答2:


If it's ending in the web-browser (I don't know your special case) try using <br/> instead of \n




回答3:


try escaping \n with single quotes and put the whole string into double quotes



来源:https://stackoverflow.com/questions/23473803/javascript-return-new-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!