Surendra Sharma

Surendra Sharma

Search This Blog

Wednesday, August 6, 2014

How to show multiple messages in alert box in JavaScript?

An alert box is used to pop up the information where user has to click “OK”.

alert("This is single line message.");

Generally we are showing single line message in alert box. But do you know how to show multiple message in single alert box?

Trick is to use “\n” after every message to separate one message with other like

alert('-1. Tajmahal in India. \n\n-2. Pyramids in Egypt. \n\n-3. Great wall of China.');

Here I want separation of two lines between each message, so I used “\n\n”.

So finally it should look like this




Please leave your comments or share this tip if it’s useful for you.

No comments:

Post a Comment