How to Create or Add jQuery Alert Message Box Using jQuery

jQuery offers many useful functions to use and perform various useful tasks for your application. The jQuery alert message is one of the best way to display notification to the users.

While writing any code, you have to use alert messages on click of the button or occuring of some event.

What is jQuery Alert Message

An alert message is a notification or information which you can provide to the user on occuring of some event. It is a message box of browser defined default size which comes on click of some button or opening of a page. When someone submitting a form or going from one page to another page you bother to display alert box.

Click this button to see the alert message now.

You can use alert message box to display warning, success or informational messages to the users come to your web page.

How to Write jQuery Alert Message

To write alert messages or important notifications for your users, you have to use the jQuery alert(). It depends upon you to which occurence of the event, you want to show the alert messages.


The content parameter requires any text content you want to show in the alert message box.


Add Line Break in jQuery Alert Message Content

When you write any content to the alert function, it displays the content without any line break. To put the line break inside the content of the alert message, you have to use symbol “\n” at the place of break point.

You can use the symbol for multiple times to put the line break. If you put “\n” for single time, you will get single line break. But, if you use it for multiple times you will get multiple line breaks.


In the above example, you will get single line break just because you have used single “\n” symbol inside the alert content.

You must also read.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.