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

To dynamically add new line break into textarea with javascript, you can use escaped \n or \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
Share on FacebookShare on TwitterShare on LinkedInSend email
Follow us on Facebook & Twitter
2022 AnswerTabsTermsContact us