How to use the -original- value of a variable in document ready function.
Hello, I've got a number of divs with the prefix menu and the suffix ## where ## is say 1-10. My code is below. It assigns the click function fine to each, but assigns them all the function based on the last value of the for loop. (It calls the current value, while I want the value from when the code was originally executed to set up the click function). Scratching my head on how to accomplish this.
-
$(function(){
for (i = 1; i <=10; i++){
$('#menu'+i).click(function(event){
nav(i,event); // <- This is where I am stumbling.
});
}
});
Much thanks for any help!