This is probably really simple, and the answer is probably really obvious, but I'm drawing a blank here.
I have an array of HTML elements that I am binding the .hover() event to. I need to know what array index was used by the event.
So let's say element[7] is hovered over, how do I pass the number 7 to that function?
Here is what I am using:
for (i=0; i<statecount; i++) {
$("#"+imagemap[i][0]).hover(function() {
// Mouse enters HTML element
alert(i);
// "i" returns 15, which makes sense because "i"
// has changed since this function was defined.
});
}