寒山 2011-9-8 23:37:36
方法一
for(var i=0; i<marker.length; i++){
marker[i].addEventListener("mouseover", function(){
this.openInfoWindow(infoWindow[i]); });
}
方法二
marker[2].addEventListener("mouseover", function(){
this.openInfoWindow(infoWindow[2]);});marker[1].addEventListener("mouseover", function(){
this.openInfoWindow(infoWindow[1]);});
这两种方式有什么区别吗? 为什么前面用循环的不可以,后面的就可以..
方法一
for(var i=0; i<marker.length; i++){
marker[i].addEventListener("mouseover", function(){
this.openInfoWindow(infoWindow[i]); });
}
方法二
marker[2].addEventListener("mouseover", function(){
this.openInfoWindow(infoWindow[2]);});marker[1].addEventListener("mouseover", function(){
this.openInfoWindow(infoWindow[1]);});
这两种方式有什么区别吗? 为什么前面用循环的不可以,后面的就可以..