melting_dog Posted February 20, 2012 Share Posted February 20, 2012 Hi all, I am building an image slider with a timer. I have everything working except for the mechanism that makes the slider go back to the start when it reaches the end. I am sure I will figure that out but there is an IF statement thats giving me trouble. Basically its meant to reset i and show the alert box IF i (the counter) is equal to the number of images (so i gets +1 for each image it shown). Troulble is its just not triggering. I just cant figure out why. Can anyone help? Code is: var totalImages = jQuery("#gallery > li").length, imageWidth = jQuery("#gallery > li:first").outerWidth(true), i = 1; while(i < totalImages){ jQuery("#gallery").delay(4000).animate({left : "-=" + imageWidth + "px"}); if(i == totalImages){ alert('The End'); i = 1; } i++; } Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/257353-image-slider-almost-working-but-just-a-little-more/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.