Fork me on GitHub

javascript中常用数组函数

1.split方法——通过分隔符,将字符串分割,导出字符数组

常用于:分割IP地址,分割文件路径(上传文件时)等等

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
        <title></title>        
        <script type="text/javascript">
            function  splitString(){
                var  str1 = "lucy,jim,wanly";
                var  arr = str1.split(",");
                for(var i =0;i<arr.length;i++)    document.write(arr[i]+"<br>");}
            splitString();    
        </script>
    </head>
    <body></body>
</html>

 

posted on 2014-03-04 10:56  雨为我停  阅读(136)  评论(0编辑  收藏  举报