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

5

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

I am already inserting the text normally in the textarea and I separate the items in commas currently:

nomUgs = selUgs.join(", ");

Instead of this comma I wanted to insert line break. How?

    
asked by anonymous 17.06.2014 / 16:41

1 answer

8

You can use \n to break the line.

Example: link

For example, this code separates each different online word:

var texto = 'Eu quero que este texto seja separado em muitas linhas!';
var linhas = texto.replace(/\s/g,'\n');
$('#testes').val(linhas);
    
17.06.2014 / 16:43