General Event Question
General Event Question
Hi, I'm trying to understand what I'm doing wrong. What I'm doing is looping through an array and adding an event. When that event is fired I need to use the index of the item in the array (to find a related div).
Here's my code:
- for (var i in $.goMap.markers) {
- google.maps.event.addListener($.goMap.markers[i],'click',function()
- {
-
- alert("Opening "+i);
- $("#res"+i).css("background","yellow");
-
- });
- }
What's happening is when the event fires i = the length of the array. I can understand why this is happening but am not sure of the right way to accomplish what I'm trying to do.
Thanks.