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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:40:05+00:00 2026-05-20T18:40:05+00:00

I am building a simple banner rotator. The fact is, when it rotates without

  • 0

I am building a simple banner rotator. The fact is, when it rotates without any buton pressed, works fine, but when I press some button to change the banner and clear the time, it doesn’t work.

Looks like the time does not clear.

        var tempo = 5000;
        var elemento;
        var quantos;
        var atual;
        
        // Inicia
        
        $(document).ready(function() {
            bannerRotator("#destaques");
        
        });
        
        
        // Funções do Banner
        
        
        function bannerRotator(element) {
            
            // Conta quantos banners existem:
            $('<ul class="buttons"></ul>').appendTo(element);
            i = 0;
            $(element).find(".banner").each(function() {
                $(element).find(".banner").eq(i).addClass("id"+i);
                buttons = element+" ul.buttons";
                acId = i+1;
                $('<li><a href="javascript:getBanner('+i+');">'+acId+'</a></li>').appendTo(buttons);
                i++;
            });
            
            // Inicia a rotacao
            elemento = element;
            quantos = i;
            rotate(i,-1);
        
        }
        
        function getBanner(r) {
            r = r-1;
            rotate(quantos, r);
        }
        
        
        function rotate(i, base) {
            
            clearTimeout(tempo);
            
            if (base<i-1) {
                base++;
                atual = base;
                setTimeout('rotate('+i+', '+base+');', tempo);
            }
            else {
                base = 0;
                atual = base;
                setTimeout('rotate('+i+', '+base+');', tempo);
            }
            
            // Faz os fades
            
            $(elemento).find(".banner").animate({opacity: 0,});
            $(elemento).find(".banner").eq(base).animate({opacity: 1,});
            
            // Arruma os botoes
            
            $(elemento).find("ul.buttons li").removeClass("active");
            $(elemento).find("ul.buttons li").eq(base).addClass("active");
            
        }
  • 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-20T18:40:06+00:00Added an answer on May 20, 2026 at 6:40 pm

    Because you’re using clearTimeout() incorrectly. Your code needs to resemble the following:

    var x = setTimeout("doStuff();", tempo);
    clearTimeout(x);
    

    You are currently using tempo as the timeout handle, which is why it isn’t working.

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

Sidebar

Related Questions

I'm building simple dictionary application using WPF. I'm using MVVM pattern, databinding and FlowDocument
I'm building simple application for myself in JSP which stores URL for me and
I'm building simple application on as3. Kind of starship game. What I want to
I'm building simple http status checker in C. I've got the network part done,
Couple of friends and i will be building simple robot to track a white
I'm building a simple Todo List application where I want to be able to
I`m building simple app which shows information about most car brands. I have rootViewController
I'am building simple Ajax application (via jquery). I have strange issue. I found where
building a simple calculator here to get my feet wet with iOS dev. I
I'm building a simple multi-user (multi-tenant?) App with ASP.NET MVC3 and EF4, one database,

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.