New lines in text within a div
Solution 1:
I think a better way to achieve this is to add
white-space: pre
or
white-space: pre-wrap
style to your div
.
See: HTML - Newline char in DIV content editable?
Solution 2:
Add this to the CSS:
white-space: pre-line
Solution 3:
Newline characters don't do any thing to html rendering. Change this in your js:
$('.message').html($('textarea[name="mensaje"]').val());
...to this:
$('.message').html($('textarea[name="mensaje"]').val().replace(/\n/g, "<br />"));
...and it will replace your newlines with a proper html line break