How to add new line breaks in textarea using Javascript ?
Would you please give me advice how to dynamically insert a new lines in textarea ? I tried to add <br /> and later \n but it doesn't work.
Hi,
To dynamically add new line break into textarea with javascript, you can use escaped \n or \r\n:
\\n
\\r\\n
Code could look like:
document.getElementById('text').value='Hello\\r\\n\\r\\nThe content...';
1 answer