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 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 site from Drupal but the primary and submenu are not aligned
I building a simple (crude, in fact) gallery in html / twig, css and
Im building a simple album and track webapp but im getting into a pickle
I'm building a simple web-based RSS reader in Python, but I'm having trouble parsing
I am building a simple Tac Tac Toe game in C++ but I get
I'm building a simple review website application and need some help with SQL Query.
I'm building a simple content app using PhoneGap + jquery mobile. My AdMob banner
when building a simple swf file, is there any good reason why i shouldn't
I am building simple notificiation system and I just wanted to know what is
Im building a simple chat client which is only supposed to be able to

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.