New line in JavaScript alert box

2022-08-29 23:21:50

How do you put in a new line into a JavaScript alert box?


答案 1

\n will put a new line in - being a control code for new line.\n

alert("Line 1\nLine 2");

答案 2

 alert("some text\nmore text in a new line");

Output:

some text
more text in a new line