textarea into array javascript
Posted
by user281180
on Stack Overflow
See other posts from Stack Overflow
or by user281180
Published on 2010-03-17T10:54:33Z
Indexed on
2010/03/17
11:01 UTC
Read the original article
Hit count: 159
jQuery
|JavaScript
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?
© Stack Overflow or respective owner