Issue passing the correct item to an other function with setTimeout
- by Moak
Here's my problem:
var slide;
$$('#slides li').each(function(i, n) {
slide = i;
setTimeout("initiateSlide()",n * 500)
});
function initiateSlide(){
i = slide;
alert(i); // pretty much alerts the last one 5 times
}
I expect to initiateSlide() with 5 different slides, instead I only get the last one 5 times.