Adding a new line in Javascript alert box- line break in alert box

here is a simple javascript for an alert box

<script type=”text/javascript”>

alert(”My name is ramanean”);

</script>

When the above javascript is executed , a alert box will appear with the text “My name is Ramanean”

<script type=”text/javascript”>

alert(”My name is ramanean,My blog is www.ramanean.com,It has useful resources”);
</script>

When the above javascript is executed , a alert box will appear with the text “My name is ramanean,My blog is www.ramanean.com,It has useful resources” on a same line

Here you can you use line breaks(\n) to move the text to a new line

Below there is a simple example of javascript using line breaks

<script type=”text/javascript”>

alert(”My name is ramanean”+’\n\n’+My blog is www.ramanean.com,+’\n\n’+It has useful resources”);
</script>

Now the text will appear in 3 different lines,when the script is executed

Leave a comment

Your comment