Home > Web Front-end > JS Tutorial > How to wrap js

How to wrap js

藏色散人
Release: 2023-01-03 09:27:15
Original
49238 people have browsed it

JS line break method: 1. Use the "\n" line break character to implement line break; 2. Use the "\r" line break character to implement line break; 3. Use HTML's
tag to implement line break. The code is as follows "document.write("First line
Second line")".

How to wrap js

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

JavaScript is an advanced, interpreted, literal scripting language. It is a prototype-based, function-first language and a multi-paradigm language.

How to wrap lines in js?

Method 1: Use line breaks

1, \nLine breaks

In JavaScript, we can use \n directly where we want to break a line:

<script>
alert("第一行\n第二行");
</script>
Copy after login

2, \r newline character

<script>
alert("第一行\r第二行");
</script>
Copy after login

The above two methods have the same results:

How to wrap js

##Method 2: Use HTML< ;br> tag [Recommended learning:

js basic tutorial]

When you can write content to an HTML document, you can use HTML's
tag to perform line breaks.

Example: Using document.write()

<script>
document.write("第一行<br>第二行")
</script>
Copy after login

Output:

第一行
第二行
Copy after login

The above is the detailed content of How to wrap js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template