日期:2014-05-16 浏览次数:20576 次
var arr = [{name:'naruto',sex:1,cloth:'orange'},
{name:'suziki',sex:1,cloth:'blue'},
{name:'sakula',sex:0,cloth:'pink'}];
console.debug(arr);
------解决方案--------------------
<IMG id=img1 SRC="" ALT="img1">
<input type="text" id="txt" name="" value="" />
<script type="text/javaScript">
function $(id){ return document.getElementById(id);}
var arr=[];
//方法1:push()
var o=$("img1");
arr.push(o);
var o=$("txt");
arr.push(o);
var o=function(){ alert("haha")};
arr.push(o);
alert(arr[0].id);
alert(arr[1].id);
arr[2]();
//方法2,直接定义赋值
var a=[$("img1"),$("txt"),function(){alert("haha")}];
alert(a[0].id);
alert(a[1].id);
a[2]();
</script>