Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New line in JavaScript alert box

Tags:

javascript

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

like image 725
Germ Avatar asked Dec 03 '09 17:12

Germ


People also ask

How do I add a br tag to an alert?

In the alert box, you can use “\n”, to break the sentence into a new line. If you want a linebreak in actual javascript, use the \n escape sequence. Do comment if you knew another way to break the sentence in a new line using JavaScript code or you have any doubts.

How do you create a line break in JavaScript?

To create a line break in JavaScript, use “<br>”. With this, we can add more than one line break also.

Can we customize alert box in JavaScript?

The standard alert box in JavaScript does not provide the option to apply CSS. To style your alert box, you need to create a custom one first. The custom alert box will be created using jQuery and styles will be applied to CSS.


1 Answers

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

alert("Line 1\nLine 2");
like image 140
Michael Gattuso Avatar answered Sep 16 '22 16:09

Michael Gattuso