WEB开发网
开发学院网页设计JavaScript javascript对象与数组的例子 阅读

javascript对象与数组的例子

 2008-08-28 19:59:30 来源:WEB开发网   
核心提示:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> <HEAD> <TITLE> New Document </TITLE> <META NAM
<!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="按钮" /></td>
  <td bgColor="red"><input type="button" value="按钮2" /></td>
 </tr>
  </table>
  <div id="out"></div>
 </BODY>
</HTML>

Tags:javascript 对象 数组

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接