jQuery pause a while loop -


i trying roll through banner images using while loop in jquery.

i need find way pause each cycle of loop banner images can cycle round slowly.

here code

var bannerimg = ['img1','img2','img3']; var counter = 0; var num = 1; while (num <= 3) { $('#header').addclass(bannerimg[counter]);    counter = counter +1;        num = num+1; } 

thanks in advance

live demo

var img = ['img1', 'img2', 'img3'],     c = 0,     run = setinterval(loop, 1000);   function loop(){    $('#header').removeclass().addclass( img[++c%img.length] );     } 

https://developer.mozilla.org/en-us/docs/javascript/reference/operators/arithmetic_operators/
http://api.jquery.com/


Comments