How to insert textarea line break in text entered via jquery/javascript?


I have a textarea and I would like to list some items in it one on each line.

I'm already entering the text normally in the textarea and I currently separate the items into commas:

nomUgs = selUgs.join(", ");

In place of this comma I wanted to insert a line break. Has as?


You can use \n to break the line.


For example this code separates each word in different line:

var texto = 'Eu quero que este texto seja separado em muitas linhas!';
var linhas = texto.replace(/\s/g,'\n');
Scroll to Top