Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6845613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:31:20+00:00 2026-05-27T00:31:20+00:00

I had a guy created a jquery plugin for me. Basically, it was 5

  • 0

I had a guy created a jquery plugin for me. Basically, it was 5 different slideshows within a slidshow. It works fine, except for one thing. Once the last slide finishes, it just stops. I need it to go back to the first slide. Can someone take a look at his code and see if they can help figure it out? Thanks.

<div id="slides">
                    <div class="slider" id="category0"> 
                        <a class="button prev" href="#" rel="nofollow"><img src="images/slidePrev.png"/></a> 
                        <a class="button next" href="#" rel="nofollow"><img src="images/slideNext.png"/></a> 
                        <div class="holder_cont"> 
                            <ul class="holder"> 
                              <li class="slide first">
                              </li> 
                              <li class="slide"> 
                              </li> 
                              <li class="slide"> 
                              </li> 
                              <li class="slide"> 
                              </li>                         
                            </ul> 
                        </div> 
                        <div class="clear"></div>                            
                   </div> 

<script>
 ;(function($) {
$.preloadImages = function(images, func) {        
    var i = 0;
    var cache = [];
    var loaded = 0;
    var num = images.length;

    for ( ; i < num; i++ ) (function(i) {
        var new_image = $('<img/>').attr('src', images[i]).load(function(){
            loaded++;

            if(loaded == num)
            {                                                
                func();                   
            }
        });                     
        cache.push(new_image);
    })(i);

    return true;
};

$.fn.imgSlider = function(images) {        
    if (!$(this).length || $(this).length>1) {            
        return this;
    }

    var direction = 'right';
    var e = this;
    var timeout_id = 0;
    var in_progress = false
    var i = 0;
    var num_slides = $(e).find('.holder > li').length;
    var slide_widths = $(e).find('.holder > li:first').width();
    var speed = 900;
    var current=0;

    for ( ; i < num_slides; i++ ) (function(i) {            
        $(e).find('.holder > li').eq(i).css('background', 'url('+images[i]+') no-repeat');
    })(i);

    function slider_animate(to)
    {
        clearTimeout(timeout_id);
        timeout_id = setTimeout(auto_animate, 5000);
        in_progress = true;            

        var toMove = $(e).find('.holder');
        current = to;

        $(toMove).animate({'margin-left':'-'+(slide_widths*to)+'px'}, speed, null, function(){                
            in_progress = false;
        });          
    }

    $(e).find('.holder > li').hover(function(){
        clearTimeout(timeout_id);            
        $(this).find('.caption').stop().fadeTo(500, 0.8);            
    },function(){
        $(this).find('.caption').stop().fadeTo(500, 0);            
        timeout_id = setTimeout(auto_animate, 3500);            
    });

    function auto_animate()
    {

        if (current === num_slides-1) {
            var foo = $('.slider:not(.hidden)').attr('id');
            if ( $(e).attr('id') === foo) {
                if ($('#category'+(parseInt(foo.slice(8))+1)).length) {
                    window.startSlider( parseInt(foo.slice(8))+1 );
                }
            }
        }

        if(direction == 'right')
        {
            var to = current+1;
            if(to<num_slides)
            {

                slider_animate(to);
            }
        }
        else
        {
            var to = current-1;
            if(to>=0)
            {
                slider_animate(to);
            }
            else
            {
                var foo = $('.slider:not(.hidden)').attr('id');
                if ( $(e).attr('id') === foo) {
                    if ($('#category'+parseInt(foo.slice(8))+1).length) {
                        window.startSlider( parseInt(foo.slice(8))+1 );
                    }
                }
            }
        }
    }

    $(e).find('.next').live('click', function(){
        if(!in_progress)
        {
            var to = current+1;

            if (current === num_slides-1) {

                var foo = $('.slider:not(.hidden)').attr('id');
                if ( $(e).attr('id') === foo) {
                    var bar = '#category' + (parseInt(foo.slice(8))+1);
                    if ($(bar).length) {
                        window.startSlider( parseInt(foo.slice(8))+1 );
                    }
                }
            }
            if(to<num_slides)
            {
                slider_animate(to);
            }
            else
            {
                slider_animate(0);
            }
        }

        return false;
    });

    $(e).find('.prev').live('click', function(){
        if(!in_progress)
        {
            var to = current-1;

            if (current === num_slides-1) {
                var foo = $('.slider:not(.hidden)').attr('id');
                if ( $(e).attr('id') === foo) {
                    if ($('#category'+parseInt(foo.slice(8))+1).length) {
                        window.startSlider( parseInt(foo.slice(8))+1 );
                    }
                }
            }

            if(to>=0)
            {
                slider_animate(to);
            }
            else
            {
                slider_animate(num_slides-1);

            }
        }

        return false;
    });

    timeout_id = setTimeout(auto_animate, 3000);

    return true;
};
})(jQuery);
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:31:21+00:00Added an answer on May 27, 2026 at 12:31 am

    Not tested, but it seems you need to make the change in the if(...) { window.startSlider } parts. For example:

    if (...) {
      window.startSlider(...);
    } else {
      window.startSlider(0);
    }
    

    It appears that if that if statement isn’t executed, your slideshow will stop; if it is, it moves onto the next slideshow. So the else should get executed when there’s no more slideshows to go through, and start at the beginning again.

    I could be reading it wrong; it’s hard to tell without a working example (jsfiddle is good for this). Hope this helps =^.^=

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Had a page that was working fine. Only change I made was to add
I have the same problem as this guy had : Setting the active executable
We had a piece of code in C in one class where we needed
Few months back, I had come across this interesting scenario asked by a guy
I had this discussion with a high reputation PHP guy: PDO has no use
ok guy I really need you super brain on this, I had pull out
Had an interesting discussion with some colleagues about the best scheduling strategies for realtime
Had a coworker ask me this, and in my brain befuddled state I didn't
Had a good search here but can't see anything that gets my mind in
I had used Server Explorer and related tools for graphical database development with Microsoft

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.