] tag, The code is [document.write("First line
Second line")].">
Methods to implement line breaks in js: 1. Use line breaks [\n, \r], the code is [alert("first line\n second line")]; 2. Use HTML [
】 tag, the code is [document.write("First line, second line")].
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, DELL G3 computer. This method is suitable for all brands of computers.
Methods to implement line breaks in js:
Method 1: Use line breaks
1,\n
Line break
In JavaScript, we can use \n directly where we want to break a line:
2,\r
Line break
Method 2: Use HTML’s
tag
When content can be written to an HTML document, you can use HTML’s < br> tag to perform line breaks.
Example: Usedocument.write()
Output:
第一行 第二行
Related free learning recommendations:javascript learning tutorial
The above is the detailed content of How to wrap lines in js. For more information, please follow other related articles on the PHP Chinese website!