js split分割字符串成数组

str = "1,2,3,4,5,6"; //这是一字符串
var strs = new Array(); //定义一数组
strs = str.split(","); //字符分割
for (i=0; i<strs.length; i++ ){
  document.write(strs[i]+"<br/>"); //分割后的字符输出
}

输出结果:

1

2

3

4

5

6
# code   js   前端  

评论

企鹅群:39438021

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×