javascript对象与数组的例子
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script type="text/javascript">
var arr = [{name:"张三",age:"1",sex:"男"},{name:"黑妞",hight:"1.5米"}];
var arr1 = [["张三","1","男"],["黑妞","1.5米"]];
function showArr(){
document.getElementById("out").innerHTML ="<br>";
for(var i=0,len = arr.length;i<len;i++){
var ob = arr[i];
for(var o in ob){
var str = ob[o];
document.getElementById("out").innerHTML += str+"<br>";
}
}
}
function showArr1(){
document.getElementById("out").innerHTML ="<br>";
for(var i=0,len=arr1.length;i<len;i++){
for(var j=0,len2=arr1[i].length;j<len2;j++){
document.getElementById("out").innerHTML += arr1[i][j]+"-----";
}
document.getElementById("out").innerHTML +="<br>";
}
}
</script>
</HEAD>
<BODY>
<table>
<tr>
<td >test</td>
<td bgColor="red">test</td>
<td bgColor="red"><input type="button" value="按钮" onclick="showArr();"/></td>
<td bgColor="red"><input type="button" value="按钮2" onclick="showArr1();"/></td>
</tr>
</table>
<div id="out"></div>
</BODY>
</HTML>