参考地址:http://luohua.iteye.com/blog/193312

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script type="text/javascript">
var arr = new Array();

//随便创建关联数组的数据如下:

arr[
"name"] = "mary";

arr[
"age"] = "3";

arr[
"sex"] = "man";

//利用 for 循环遍历如下:
for( var key in arr)
{
// 则上面 key 变量所取的值为 "name" 或 "age" 或 "sex",
//而不是数组的值
// 下面的 value 才是取到对应的值
alert(arr[key]);
}
</script>
</head>

<body>

</body>
</html>

  

相关文章:

  • 2021-11-21
  • 2021-07-08
  • 2021-10-17
  • 2022-12-23
  • 2022-12-23
  • 2021-10-24
  • 2021-06-22
猜你喜欢
  • 2021-09-07
  • 2022-02-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案