javascript jQuery 换行 \n

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6246690/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 20:02:41  来源:igfitidea点击:

jQuery new line \n

javascriptjquerynewlineline

提问by daryl

Possible Duplicate:
What's the cleanest way to write a multiline string in JavaScript?

可能的重复:
在 JavaScript 中编写多行字符串的最简洁方法是什么?

How does one go onto a new line in writing jQuery code not the actual output of the code, for example:

如何在编写 jQuery 代码而不是代码的实际输出时换行,例如:

$('#foo').append('<div id="bla"> '+\n+'
                  </div>');

Something like that.

类似的东西。

回答by Greg Flynn

$('#foo').append('<div id="bla"> \
                 </div>');

The slash (\) escapes the newline, allowing the string to span multiple lines

斜线 (\) 转义换行符,允许字符串跨越多行