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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:48:11+00:00 2026-05-27T11:48:11+00:00

Problem: Whenever I click faster or slower I need last .click() call to finish

  • 0

Problem: Whenever I click faster or slower I need last .click() call to finish before the next one starts. If you click the button faster , in the given example, you can see it’s leaving divisions with 0 opacity.

What I want to achieve is stacking up till 3-4. I tried some queue code examples, couldn’t make it work.

$("#addNew").click(function(){
    var _this = $("#scrollable");
    //Switch classes
    _this.find("div.first").switchClass("first","second",500);
    _this.find("div.second").switchClass("second","third",500);
    _this.find("div.third").switchClass("third","fourth",500);
    _this.find("div.fourth").switchClass("fourth","fifth",500);
    // Insert first/new line
    $("<div class='first'>Hello!</div>").css("opacity","0").hide().prependTo(_this).slideDown(function(){$(this).stop().animate({opacity:1},300)})
    $("div.fifth").fadeOut().remove();
});

Here is example: http://jsfiddle.net/gtFyP/5/

  • 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-27T11:48:12+00:00Added an answer on May 27, 2026 at 11:48 am

    Use setInterval

    You could combine the below flag solution with setInterval, and thus be able to process clicks occurring during an animation.

    Updated your JS Fiddle again with this alternate solution.

    $(function() {
        var clicking = false;
        var clickCache = 0;
    
        window.setInterval(function(){
            if (!clicking && clickCache) {
                processClick();
                clickCache--;
            }
        }, 100);
    
        var processClick = function() {
             var _this = $("#scrollable");
    
            //Switch classes
            _this.find("div.first").switchClass("first", "second", 500);
            _this.find("div.second").switchClass("second", "third", 500);
            _this.find("div.third").switchClass("third", "fourth", 500);
            _this.find("div.fourth").switchClass("fourth", "fifth", 500);
    
    
            clicking = true;
            // Insert first/new line
            $("<div class='first'>Hello!</div>").css("opacity", "0").hide().prependTo(_this).slideDown(function() {
                $(this).stop().animate({
                    opacity: 1
                }, 300, function(){
                    clicking = false;
                });
            });
            $("div.fifth").fadeOut().remove();
        };
    
        $("#addNew").click(function() {
            clickCache++;
        });
    });
    

    Use a Flag

    You could use a flag – only start an animation if it’s false. When you start animating, set it to true, when the animation is done, set it back to false.

    I’ve modified your JS Fiddle.

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

Sidebar

Related Questions

My problem is whenever I left click a dynatree node then right click another
Problem: I have a confirmation box which pops up whenever I click on the
I have the following code that runs whenever you click the Start button on
I have the same problem, my site opens a new tab whenever I click
I have a problem with chrome running C# webdriver. Whenever i click a link
I just cannot get this to work! Whenever I click the button nothing happens.
I've been working on an Entity, oneToMany relationship, the problem is that whenever I
problem is , that whenever the grid's row is right clicked the selected item
I have a problem with using the prefix, seems like whenever I use the
I am getting this annoying problem, whenever i do some changes to any file

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.