var arr={7,8,9};
$.each(arr,function(item) { alert(item); });
var arr={"tou";30,"joy";20,"lily";40};
$.each(arr,function(key,value){alert(key+""+value);});
在vs2010上一直没调试成功,是什么原因,帮我看看吧
------解决方案--------------------
你应该这样
<script>
var arr=[7,8,9];//定义数组,{}是定义对象
$.each(arr,function(item) { alert(this + " = " + item); });
var arr2={"tou":30,"joy":20,"lily":40};//定义对象是:而不是;
$.each(arr2,function(key,value){alert(key+" = "+value);});
</script>
------解决方案--------------------
var arr=[7,8,9];
$.each(arr,function(item) { alert(arr[item]); });
var arr={"tou":30,"joy":20,"lily":40};
$.each(arr,function(key,value){alert(key+""+value);});
看一下Javascript: The Good Parts这本书,里面对javascript的数组有详细的分析