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

  • SEARCH
  • Home
  • 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 4045412
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:25:26+00:00 2026-05-20T13:25:26+00:00

my slideshow is running through once and not restarting once it has run through.

  • 0

my slideshow is running through once and not restarting once it has run through. I have posted all the code I have below.

        $(document).ready(function() {
        $('img.banner1').show();
        $('div.banner1').show();
        $('.nav ul li:nth-child(3)').addClass('child3');
        $('.nav ul li:nth-child(4)').addClass('child4');
        promoCycle = setInterval('cycle()', 5000);
    });

    $('a.banner2').mouseover(function() {
    $('.banner img.banner2').show();
    $('.banner .texts div.banner2').show();
    $('.banner .buttons ul li.banner1,.banner .buttons ul li.banner3,.banner .buttons ul li.banner4,.banner .buttons ul li.banner5').removeClass('on');
    $('.banner .texts div.banner1,.banner .texts div.banner3,.banner .texts div.banner4,.banner .texts div.banner5').hide();
    $('.banner img.banner1,.banner img.banner3,.banner img.banner4,.banner img.banner5').hide();
    clearInterval(promoCycle);
});
$('a.banner3').mouseover(function() {
    $('.banner img.banner3').show();
    $('.banner .texts div.banner3').show();
    $('.banner .buttons ul li.banner1,.banner .buttons ul li.banner2,.banner .buttons ul li.banner4,.banner .buttons ul li.banner5').removeClass('on');
    $('.banner .texts div.banner1,.banner .texts div.banner2,.banner .texts div.banner4,.banner .texts div.banner5').hide();
    $('.banner img.banner1,.banner img.banner2,.banner img.banner4,.banner img.banner5').hide();
    clearInterval(promoCycle);
});
$('a.banner4').mouseover(function() {
    $('.banner img.banner4').show();
    $('.banner .texts div.banner4').show();
    $('.banner .buttons ul li.banner1,.banner .buttons ul li.banner3,.banner .buttons ul li.banner2,.banner .buttons ul li.banner5').removeClass('on');
    $('.banner .texts div.banner1,.banner .texts div.banner3,.banner .texts div.banner2,.banner .texts div.banner5').hide();
    $('.banner img.banner1,.banner img.banner3,.banner img.banner2,.banner img.banner5').hide();
    clearInterval(promoCycle);
});
$('a.banner5').mouseover(function() {
    $('.banner img.banner5').show();
    $('.banner .texts div.banner5').show();
    $('.banner .buttons ul li.banner1,.banner .buttons ul li.banner3,.banner .buttons ul li.banner4,.banner .buttons ul li.banner2').removeClass('on');
    $('.banner .texts div.banner1,.banner .texts div.banner3,.banner .texts div.banner4,.banner .texts div.banner2').hide();
    $('.banner img.banner1,.banner img.banner3,.banner img.banner4,.banner img.banner2').hide();
    clearInterval(promoCycle);
});
$('.banner .buttons').mouseout(function() {
    $('.banner .buttons ul li.banner2,.banner .buttons ul li.banner3,.banner .buttons ul li.banner4,.banner .buttons ul li.banner5').removeClass('on');
    $('.banner .texts div.banner2,.banner .texts div.banner3,.banner .texts div.banner4,.banner .texts div.banner5').hide();
    $('.banner img.banner2,.banner img.banner3,.banner img.banner4,.banner img.banner5').hide();
    $('.banner img.banner1').show();
    $('.banner .texts div.banner1').show();
    clearInterval(promoCycle);
});
var count = 1;
function cycle(){
    count++;
    if (count == 2) {
        $('.banner .buttons li.banner2').addClass('on');
        $('.banner img.banner2').show();
        $('.banner .texts div.banner2').show();
        $('.banner .buttons ul li.banner1,.banner .buttons ul li.banner3,.banner .buttons ul li.banner4,.banner .buttons ul li.banner5').removeClass('on');
        $('.banner .texts div.banner1,.banner .texts div.banner3,.banner .texts div.banner4,.banner .texts div.banner5').hide();
        $('.banner img.banner1,.banner img.banner3,.banner img.banner4,.banner img.banner5').hide();
    }
    if (count == 3) {
        $('.banner .buttons li.banner3').addClass('on');
        $('.banner img.banner3').show();
        $('.banner .texts div.banner3').show();
        $('.banner .buttons ul li.banner1,.banner .buttons ul li.banner2,.banner .buttons ul li.banner4,.banner .buttons ul li.banner5').removeClass('on');
        $('.banner .texts div.banner1,.banner .texts div.banner2,.banner .texts div.banner4,.banner .texts div.banner5').hide();
        $('.banner img.banner1,.banner img.banner2,.banner img.banner4,.banner img.banner5').hide();
    }
    if (count == 4) {
        $('.banner .buttons li.banner4').addClass('on');
        $('.banner img.banner4').show();
        $('.banner .texts div.banner4').show();
        $('.banner .buttons ul li.banner1,.banner .buttons ul li.banner3,.banner .buttons ul li.banner2,.banner .buttons ul li.banner5').removeClass('on');
        $('.banner .texts div.banner1,.banner .texts div.banner3,.banner .texts div.banner2,.banner .texts div.banner5').hide();
        $('.banner img.banner1,.banner img.banner3,.banner img.banner2,.banner img.banner5').hide();
    }
    if (count == 5) {
        $('.banner .buttons li.banner5').addClass('on');
        $('.banner img.banner5').show();
        $('.banner .texts div.banner5').show();
        $('.banner .buttons ul li.banner1,.banner .buttons ul li.banner3,.banner .buttons ul li.banner4,.banner .buttons ul li.banner2').removeClass('on');
        $('.banner .texts div.banner1,.banner .texts div.banner3,.banner .texts div.banner4,.banner .texts div.banner2').hide();
        $('.banner img.banner1,.banner img.banner3,.banner img.banner4,.banner img.banner2').hide();
    }
    if (count == 6) {
        $('.banner img.banner1').show();
        $('.banner .texts div.banner1').show();
        $('.banner .buttons ul li.banner2,.banner .buttons ul li.banner3,.banner .buttons ul li.banner4,.banner .buttons ul li.banner5').removeClass('on');
        $('.banner .texts div.banner2,.banner .texts div.banner3,.banner .texts div.banner4,.banner .texts div.banner5').hide();
        $('.banner img.banner2,.banner img.banner3,.banner img.banner4,.banner img.banner5').hide();
        clearInterval(promoCycle);
    }
}
  • 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-20T13:25:27+00:00Added an answer on May 20, 2026 at 1:25 pm

    Your trouble is your are using clearInterval after the last banner. This stops the cycle from repeating. Instead, you should reset count to 1 and remove the call to clearInterval.

    Also, it looks like your mouseout code is trying to resume the cycle. Instead of clearInterval, you should again use promoCycle = setInterval(cycle, 5000).

    All that being said… Holy code-bloat batman! You can pare down that code dramatically! Here’s a shot I took at it (untested, since I don’t have your html):

    var promoCycle = 0;
    $(function ()
    {
        $('img.banner1, div.banner1').show();
        $('.nav ul li:nth-child(3)').addClass('child3');
        $('.nav ul li:nth-child(4)').addClass('child4');
        promoCycle = setInterval(showBanner, 5000);
        $('a.banner1').mouseover(bannerHover(1));
        $('a.banner2').mouseover(bannerHover(2));
        $('a.banner3').mouseover(bannerHover(3));
        $('a.banner4').mouseover(bannerHover(4));
        $('a.banner5').mouseover(bannerHover(5));
        $('.banner .buttons').mouseout(function ()
        {
            promoCycle = setInterval(showBanner, 5000);
        });
    });
    function bannerHover(i)
    {
        return function ()
        {
            bannerIndex = i;
            showBanner();
            clearInterval(promoCycle);
        };
    }
    var bannerIndex = 0
    function showBanner()
    {
        var index = (bannerIndex++ % 5) + 1;
        $('.banner .texts div[class*=banner],banner img[class*=banner]').hide();
        $('.banner .buttons ul li.on[class*=banner]').removeClass('on');
        $('.banner .buttons li.banner' + index).addClass('on');
        $('.banner img.banner'+index+',.banner .texts div.banner'+index).show();
    }
    

    I would actually go further and replace class="banner1" with <div banner="1"> (for all bannerX elements, not just divs). This way you can use jQuery selectors like:

    $(".banner div[banner=1]");
    $("a[banner]");
    $(this).attr("banner");
    

    For example, binding $("a.bannerX").mouseover would be simplified from 5 calls to just one with no need for a function constructor:

    $("a[banner]").mouseover(function()
    {
        bannerIndex = parseInt($(this).attr("banner"));
        showBanner();
        clearInterval(promoCycle);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application which behaves as a slideshow for all pictures in a
I have this page that i have a rotate slideshow running. I have it
I have posted a sample jQuery slideshow on my blog here: robertmarkbramprogrammer.blogspot.com/2010/09/jquery-slideshow.html In Chrome,
I am trying to create an easy slideshow but It is not that easy
I am building a slideshow with a few hundred images and would like to
I'm using the jQuery Cycle plugin to cycle through some images on a webpage.
I'm running around in circles trying to figure out why I can't get jQuery
I am using lightbox slideshow and it is working fine, there is Next-Prev button
I installed Slideshow pro, with swfobject here: http://globalhealth-dev.oit.duke.edu/whos-involved/alumni The flash loads but the images
(function($){ $.fn.slideshow = function(){ function init(obj){ setInterval(startShow(), 3000); } function startShow(){ alert('h'); } return

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.