Question about Passing Value to JavaScript Callback Functions:
Variable in JavaScript callback functions always gets last value in loop?
I'm having trouble passing the value of 'k' to the callback function within the fadeOut method. Here is my loop code snippet:
for(var k=0; k<image1.length; k++)
{
$(img[k]).fadeOut(200, function(k) {
alert(k);
$(this).attr('src', image2[k]);
$(this).fadeIn(200);
});
}