-3

I am trying to create an array from a text field. I need to paste fifty lines into a text field. Then convert the lines to an array, with each line being a different element in the array.

4

1 回答 1

2

给定这样的输入字段:

<textarea id="myInput"></textarea>

您可以从文本字段中获取值,如下所示:

var myValue = document.getElementById("myInput").value;

然后像这样拆分

var myArray = myValue.split("\n");
于 2013-08-10T02:01:51.383 回答