将字符串转化成数组,并以列表的形式在文档中输出
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script type="text/javascript">
var ball="篮球,地球,足球,火球,什么"
var ball1=ball.split(",");
document.write("<ol>");
for(var n=0;n<ball1.length;n++){
document.write("<li>"+ball1[n]+"</li>");
}
document.write("</ol>");
</script>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script type="text/javascript">
var ball="篮球,地球,足球,火球,什么"
var ball1=ball.split(",");
document.write("<ol>");
for(var n=0;n<ball1.length;n++){
document.write("<li>"+ball1[n]+"</li>");
}
document.write("</ol>");
</script>
</body>
</html>