How to replace \n with <br /> in JavaScript?
Replace with global scope
$('#input').val().replace(/\n/g, "<br />")
or
$('#input').val().replace("\n", "<br />", "g")
it could be done like this:
$('textarea').val().replace(/\n/g, "<br />");
edit: sorry ... the regular expressions in javascript should not be quoted
working example