ers[0].addEventListener("mouseover", function(){this.openInfoWindow(infoWindows[0]);});
ers[1].addEventListener("mouseover", function(){this.openInfoWindow(infoWindows[1]);});
ers[2].addEventListener("mouseover", function(){this.openInfoWindow(infoWindows[2]);});
ers[3].addEventListener("mouseover", function(){this.openInfoWindow(infoWindows[3]);});
ers[4].addEventListener("mouseover", function(){this.openInfoWindow(infoWindows[4]);});
ers[5].addEventListener("mouseover", function(){this.openInfoWindow(infoWindows[5]);});
ers[6].addEventListener("mouseover", function(){this.openInfoWindow(infoWindows[6]);});
ers[7].addEventListener("mouseover", function(){this.openInfoWindow(infoWindows[7]);});
ers[8].addEventListener("mouseover", function(){this.openInfoWindow(infoWindows[8]);});
ers[9].addEventListener("mouseover", function(){this.openInfoWindow(infoWindows[9]);});上面的规律写法,我想用一个循环解解决,结果是错误的,求正确写法,谢谢
错误的写法如下
for(i=0;i<ers.length;i++){ers[i].addEventListener("mouseover", function(){this.openInfoWindow(infoWindows[i]);});
}