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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:53:24+00:00 2026-06-15T09:53:24+00:00

Currently I have something setup where a user clicks on an image and based

  • 0

Currently I have something setup where a user clicks on an image and based off that image, a div will fade in / fade out.

If the user goes crazy and clicks on a bunch of the images at the same time, multiple divs load rather than just the last requested one.

I’ve tried to illustrate my problem here.
http://jsfiddle.net/BBgsf/

Clicking on any of those images will load the corresponding div with the number. But if you click on different images before the animation is completed, it loads the other divs as well.

jQuery

$(".flow-chart img").click(function () {

    var div_class = $(this).data("class");

    $(".hide_show:visible").fadeOut('slow', function() {
        $("."+div_class).fadeIn("slow");
    });

});

HTML

<div class="1 hide_show">1</div>
<div class="2 hide_show" style="display: none">2</div>
<div class="3 hide_show" style="display: none">3</div>

How can I prevent the multiple divs from loading rather than just one at a time?

​

  • 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-06-15T09:53:25+00:00Added an answer on June 15, 2026 at 9:53 am

    One way to do this is to keep track of if an animation is currently active. Here is a simple way to do this: http://jsfiddle.net/QCWgR/

    var active = false;
    
    $(".flow-chart img").click(function () {
        if (active) {
            return;
        }
        active = true;        
        var div_class = $(this).data("class");
    
        $(".hide_show:visible").fadeOut('slow', function() {
            // note the callback that sets active to false at end of animation
            $("."+div_class).fadeIn("slow", function() { active = false; });
        });
    
    });
    

    With this approach, the first click has to complete the animation cycle before the next one will happen.

    Using closure to keep active out of global namespace

    To keep active out of global namespace you can run the whole block inside an anonymous closure like so:

    http://jsfiddle.net/QCWgR/2/

    (function () {
        var active = false;
    
        $(".flow-chart img").click(function () {
            if (active) {
                return;
            }
            active = true;        
            var div_class = $(this).data("class");
    
            $(".hide_show:visible").fadeOut('slow', function() {
                $("."+div_class).fadeIn("slow", function() { active = false; });
            });
    
        });
    })();​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have something like this currently: <div class = className style = position: absolute;
I currently have a table structure that looks something like this(some details omitted): ColumnName
I currently have service classes that look something like this public class UserService :
We currently have an ant task that contains something similar to the following: <filelist
I currently have some action associated with when the user types something in a
Currently I have a site where it has a header that looks something like
I currently have a client website on the Grid server on MediaTemple that will
Currently I have a C# solution that contains a class library, installer, and setup
Very simple + silly question: Does clojure provide multi maps? I currently have something
Currently, I have something like: public partial class Form1 : Form { delegate void

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.