程序员人生 网站导航

js用法例子:使用split分隔指定字符串

栏目:jscript时间:2013-10-21 04:39:42

js用法例子:使用split分隔指定字符串

JavaScript使用split分隔指定字符串,用法举例,这里使用“,”逗号作为分隔符,将一长串含有逗号的字符串分开,应用十分广泛,其用法也相当简单,你从本代码中即可学到用法。

<html>
<head>
<title>使用指定的字符分割字符串</title>
</head>
<body>
<script language="javascript">
<!--
name = "张三,李四,王五";
ch = new Array;
ch = name.split(",");
for(i=0;i<ch.length;i++){
document.write(ch[i],"<br>");
}
//-->
</script>
</body>
</html>
------分隔线----------------------------
------分隔线----------------------------

最新技术推荐