Issue passing the correct item to an other function with setTimeout
Posted
by Moak
on Stack Overflow
See other posts from Stack Overflow
or by Moak
Published on 2010-06-09T04:12:24Z
Indexed on
2010/06/09
4:22 UTC
Read the original article
Hit count: 192
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.
© Stack Overflow or respective owner