Look at the following code.
for(i=1;i<=10;i++){
$('#field'+i).click(function(){
alert(i);
});
}
When I click one of those fields I get an 11. Of course I know why: Because at the moment I click it the value of the variable i
is 11. But I guess you know what I actually want. How do I do that?