I have added a "play" button to my image gallery slideshow, now when i press this button the pictures should change every 3000 mlsec for example.
I know that i need use "setTimeout()" inside the for loop, while my var i will not reach the value of the array_pics.lenght. But i can't make it work.
play.onclick = function play() {
var i;
var ind = index;
document.getElementById('largeImg').src = arr_big[index].src;
//Tryed to put slide() function inside the for loop which was inside setTimeout(), get a syntax errors.
var slide = function slide() {
i = ind;
ind += 1;
index = ind;
document.getElementById('largeImg').src = arr_big[ind].src;
};
slide(); //I have tryed setTimeout(slide(), 3000) here inside the for loop. Does not work!
};
Can someone help me to make it work? How i can use setTimeout() and for loop? Thanks.