<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>数组遍历</title>
<style
type="text/css">
#show{
font: 16px;
background:red;
width:200px;
}
</style>
<script
type="text/javascript" >
var a
= [3,5,6,2,1,4];
var
str="";
document.write("<div
id=‘show‘>");
for(var
i=0;i<a.length;i++)
{
str+="数组的第"+(i+1)+"个元素:"+a[i]+"<br/>";
}
document.write(str+"</div>");
</script>
</head>
<body>
</body>
</html>
结果:
数组的第1个元素:3
数组的第2个元素:5
数组的第3个元素:6
数组的第4个元素:2
数组的第5个元素:1
数组的第6个元素:4
原文:http://www.cnblogs.com/lowbrid/p/3552902.html