Jump to content

Recommended Posts

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!

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.