I have a code for an Autocomplete input that will add to a textarea element the value that is choosen on the Autocomplete input, as a list seperated by new row.
When adding rows to the textarea seperatly, by pressing Enter for a new row, it expands to fill in the new row and value, however, in my case, when using +('\n') a new line is created but the textarea is not expanding. I guess that it got to do with the functionality of Enter vs \n. So is there a different way to create a newline that textarea will also expand?
My code snippet is:
b.addEventListener("click", function(e) {
/*insert the value for the autocomplete text field:*/
document.getElementById('myTxt').focus();
document.getElementById('myInput').focus();
myTxt.value += this.getElementsByTagName("input")[0].value + ('\n');
inp.value = "";
\r = CR (Carriage Return) → Used as a new line character in Mac OS before X\n = LF (Line Feed) → Used as a new line character in Unix/Mac OS X\r\n = CR + LF → Used as a new line character in Windows