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.
21 Jun 2019 at 07:23 PM
0pnshow more
onefiveonefive
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...';
24 Jun 2019 at 07:02 PM
0pnshow more
TimTim
Share on FacebookShare on TwitterShare on LinkedInSend email
2021 AnswerTabsTermsContact us