textarea into array javascript
- by user281180
myList contains the following values:
value1
value2
value3
function showArray() {
var txt = $("#myList").text();
var textread = txt.split('\n');
var msg = "";
for (var i = 0; i < textread .length; i++) {
msg += i + ": " + textread [i] + "\n";
}
alert(msg);
}
my alert gives me the following:
0:value1
value2
value3
It`s not what I wanted and expecting, I was expecting something like:
0: value1
1: value2
2: value3
How can I get the values as expected?