domoindal
domoindal

Reputation: 1533

Insert text in a div container

I have a textarea where i get it's content and send it to database via ajax. When i get such content and insert it in a DIV, new lines are not considered, so the content is pasted as a whole without LF.

I used jQuery templates for printing the result of my query and within the template the mentioned div is:

<div class="message">${msg}</div>

where ${msg} is the message gathered from the database with CR.

Is there anything I could do for avoiding that?

Upvotes: 0

Views: 272

Answers (1)

nvrandow
nvrandow

Reputation: 730

You use php, do you? So you can convert normal line breaks (\n) to HTML line breaks (<br />) with nl2br().

Upvotes: 2

Related Questions