Possible Duplicate:
Variable in JavaScript callback functions always gets last value in loop?
I am not able to pass the value of k to the callback function of fadeOut function. my loop is as given below.
for(var k=0;k<image1.length;k++)
{
$(img[k]).fadeOut(200,function(k) {
alert(k);
$(this).attr('src', image2[k]);
$(this).fadeIn(200);
});
}