![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to Line Breaks to JavaScript Alert?
To add line breaks to JavaScript alert, use “\r
”. In the following example, we will see how to display text in JavaScript alert.
Example
<html> <body> <script> function DisplayAlert() { var newLine = "\r
" var msg = "Showing how to add line break." msg += newLine; msg += "Line Break can be easily added in JavaScript."; msg += newLine; msg += "Simply Easy Learning"; msg+= newLine; msg += "TutorialsPoint.com"; alert(msg); } </script> <input type = "button" value = "Click" onclick = "DisplayAlert()" /> </body> </html>
Advertisements