Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript replace
with n

var str = $("#mydiv").html();
var regex = /<brs*[/]?>/gi;
$("#mydiv").html(str.replace(regex, "
"));
Comment

replace line break with html line break js

let multilineString = `My
text
1
2
3

4
is
here`;

let htmlText = multilineString.replace(/(
|

|
|
)/g, '<br>');

console.log('Multiline string: ' + multilineString);
console.log('HTML text: ' + htmlText);
Comment

PREVIOUS NEXT
Code Example
Javascript :: location reload after 2 seconds 
Javascript :: number of properties in object javascript 
Javascript :: select2 destroy 
Javascript :: array sort using for loop in javascript 
Javascript :: java sleep 1 sec 
Javascript :: javascript capitalize words 
Javascript :: javascript window resize listener 
Javascript :: bootstrap italics 
Javascript :: dinosaur game 
Javascript :: add id jquery 
Javascript :: explode in jquery 
Javascript :: float right react native 
Javascript :: javascript check for undefined 
Javascript :: disable sequelize logging 
Javascript :: how to get the first key in a n object in javascript 
Javascript :: gitignore all node_modules 
Javascript :: 1line uuid 
Javascript :: how to Store Objects in HTML5 localStorage 
Javascript :: javascript remove line breaks from string 
Javascript :: mui typography bold 
Javascript :: react install 
Javascript :: javascript how to check for an empty object 
Javascript :: javascript get element height and width 
Javascript :: javascript trello title swap 
Javascript :: how to get year in react 
Javascript :: import react icons module 
Javascript :: react native scrollview horizontal 
Javascript :: how #region javascript 
Javascript :: js set important style 
Javascript :: js get numbers only 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =