How to break a line in JavaScript

{0 Comments}

To break a line in JavaScript we can find space or a special character with the help of regular expression then we can replace the same with </br> tag which will actually break the line of the particular message so the sample code for that is as follows:

 Javascript |  copy code |? 
1
var div = document.getElementById('message').innerHTML = text.replace(/(\r\n)|(\n)/g,"<br />")

Leave a Comment

Your email address will not be published.