Rama Lingam Rama Lingam - 6 months ago 24
jQuery Question

br tag is not working while replace the content from textarea to DIV using JQUERY text function

The br tag is not working on DIV.
I am getting the message from Update Content:

The message have the 2 lines like "Rama" next line "Lingam".
But the result is "Rama
Lingam" by

How to make a new line in DIV?

Here is my code:

function updateQuotes(){
var weg_quotes = $("#weg_quotes_Q_013").val();
replaceContent = weg_quotes.replace("\n", "<br>", "g");

Update Content: <textarea placeholder="Update your content..." id="weg_quotes_Q_013" name="weg_quotes" cols="80" rows="3" class="appQuotesTextarea" maxlength="200" required=""></textarea>
<button onclick="updateQuotes()" id="Q_013" name="update-btn" class="appQuotesBtn">Update</button>

<div id="editQuotesRowLabel_Q_013" class="appQuotesLabel">
This is content div.


To insert HTML content using jquery you need to use .html() instead of .text(). So in your case you end up with :

 //                              |_ use html() instead of text()

Source :