1.对textarea作用域多行的操作
<textarea id="dataArry">
132134
asdfasd
</textarea>
得到作用域内的各行组成的数组:
var data = document.getElementById("dataArry").value;
var arry = data.split("\r\n");
注:换行的正则为'\r\n';
2.获取textarea作用域中第某行的值
function(num){
var data = document.getElementById("dataArry").value;
var arry = data.split("\r\n");
for(var i=0; i<arry.length;i++){
alert(arry[num-1]);
}
}
3.获取下拉列表的option值
<select id="china">
<option value="1" selected>中国</option>
<option value="2">俄罗斯</option>
</select>
取值(获取选中的option值):var data= document.getElementById("china").options[window.document.getElementById("china").selectedIndex].text;
结果:中国