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 6191471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:46:14+00:00 2026-05-24T02:46:14+00:00

Why does setInterval run very fast after some time? I used the code below

  • 0

Why does setInterval run very fast after some time? I used the code
below for a background slideshow on my site. I also use the fullpage preloader plugin.

function slideSwitch() {
    var $active = $('#slideshow IMG.active');
    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
    var $next =  $active.next().length ? $active.next() : $('#slideshow IMG:first');
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 9999);
});

//use fullpage preloader
QueryLoader.init();

I want to repeat the animation every 9999 milliseconds. But after some time (5-7 minutes), the animation seems to repeat every 1000 milliseconds.

  • 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-24T02:46:19+00:00Added an answer on May 24, 2026 at 2:46 am

    the javascript function setInterval() returns a handle

    handle = setInterval("slideSwitch()", 9999);
    

    that you can clear whenever you want with clearInterval

    function killInterval(){
       clearInterval(handle);
    }
    

    So you’d have to clean your interval after some time, for that you want to use setTimeout

    setTimeout("killInterval()",3000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Relatively new to JQuery. I've got some code that does a banner swap with
I have the following code: var counter = 0; setInterval(run, 10); function run() {
In my application I found some JavaScript code that is using setInterval with 0
Does anyone remember the XMP tag? What was it used for and why was
I have a function called goRight() which does some stuff when I click a
I'm trying to make some code which finds if a div exists, and if
I've run into an issue with a simple javascript code, which is pretty much
Why when calling fadeIn() onLoad does the browser run through the loop immediately. In
For some odd reason Internet Explorer won't run my queries properly. I designed this
How does setInterval handle callback functions that take longer than the desired interval? I've

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.