In this tutorial, learn how to add line breaks in alert message box for new line using jQuery. Create your own jQuery alert box with line breaks in text messages. Add breaks in jQuery alerts with the answer given here in the example given below.

An alert is the simple way of showing notifications to the user when they perform some actions. This is the simple way still using by many developers and coders to design a code and show errors or notification in the alert message box.

jQuery Add Line Breaks in Alert Message Box for New Line

To create an alert with line break, you have to use the symbol \n inside the alert where you want to put the line breaks. If you don’t know how to create alert message box, you can see our tutorial on creating jQuery alert message box.

Below is the simple example contains the alert function with the simple text content. You can add line breaks in alert message box using the \n symbol inside the alert message box.


Click the above button to see the alert message with the line breaks. Here, you can see there is only one line breaks in the alert message box. However, you can add as many as line breaks as you want. You can also add alert message on click of any HTML element using the id of the HTML element.

Hope, you like this tutorial. If you have any query, please comment below to get the solution of your query. Also tell me, which method are you using to create alert message box with line breaks.

Leave a Reply

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.