var newimages=[] var imgArr = ['images/banner.jpg','images/grid-bg.png','images/grid-bg00.png','images/grid-bg01.png', 'images/grid-bg02.png','images/grid-bg03.png','images/grid-bg04.png']; function loadImage(imgArr){ var Num = 0; var imgArr = (typeof imgArr != 'object') ? [imgArr] : imgArr;////确保参数总是数组 for(var i=0; i<imgArr.length; i++){ newimages[i] = new Image(); newimages[i].index = i; newimages[i].src = imgArr[i]; newimages[i].onload = function(){ Num++; console.log(Num); } } } loadImage(imgArr);