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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:47:01+00:00 2026-05-26T10:47:01+00:00

Hi I am trying to create an layered image effect but I am having

  • 0

Hi I am trying to create an layered image effect but I am having trouble queueing a function along with jquery animation.

Basically I need to hide all of my .bar divs then execute the function after which will make them fadeIn one at a time. I need to do it this way as there will be multiple images and this effect will be what creates the transition between them.

<div class="container">
<div class="image">
    <div class="bar">
    </div>
    <div class="bar">
    </div>
    <div class="bar">
    </div>
    <div class="bar">
    </div>
    <div class="bar">
    </div>
    <div class="bar">
    </div>
    <div class="bar">
    </div>
    <div class="bar">
    </div>
    <div class="bar">
    </div>
    <div class="bar">
    </div>
    <div class="bar">
    </div>
    <div class="bar">
    </div>
    <div class="bar">
    </div>
    <div class="bar">
    </div>
</div>

and the css is like this

.container {width:700px;height:400px;margin:0 auto;background:#FF0;}
.image {background:green; width:700px; height:300px; }
.bar { height:300px; width:50px; background:orange; float:left;}

and the javascript/jquery is like this

$(function(){

var i = -1;

function fading(){
    function fader(){
    setTimeout(function () {          
          i++;                    
          if (i < 15) {          
             $('.bar:eq(' + i + ')').fadeIn('200');
             fader();           
          }                       
       }, 100)
    }
    fader()
}

$('input').click(function(){

    $('.bar').hide().queue(function(){
                    fading()
                    $('this').dequeue();
                    });
});


});

If anyone has ideas on how this can be done differently or achieved in the way I have laydd out that would be great

  • 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-26T10:47:01+00:00Added an answer on May 26, 2026 at 10:47 am

    You can’t use the animation queue in this way because your .queue call is getting mixed in with all the fadeIn() calls and won’t wait until after those as they are using the animation queue also. You could create some separate queue and use that, but that is probably not worth it.

    Why not just have the fader() function trigger your next action when it finishes with the 15 layers?

    Or, you can pass a callback function into fader() which it can call when it’s done with the 15 layers?

    I don’t get exactly what you’re trying to do, but you can kick off another function in here when you’re done fading in the 15 layers (see where I added the else):

    function fading() {
        var cntr = -1;
        function fader() {
           setTimeout(function () {          
              cntr++;
              if (cntr < 15) {          
                 $('.bar:eq(' + cntr + ')').fadeIn('200');
                 fader();           
              } else {
                 // done fading in the 15 items, now you can call some other function
                 // here to start the next operation
                 afterFade();
              }
           }, 100);
        }
        fader();
    }
    

    Try simplifying your click code to this:

    $('input').click(function(){
        $('.bar').hide();
        fading();
    });
    

    .hide() is synchronous (it doesn’t use the animation queue) so you can just call fading() right after it.

    You also have to reinitialize your cntr variable on the second call to fading(). In my code example above, I changed the name of the variable from i to cntr and moved it’s definition and initialization into the top of the fading() function so it is automatically initialized on each subsequent call.

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

Sidebar

Related Questions

I am trying create the image enlargement effect when you hover your mouse over
I am trying create a search word puzzle box with JQuery. Basically a table
All, I am trying create a 'to & fro' animation using jquery animate &
Trying to create a user account in a test. But getting a Object reference
I'm trying create a RCP Application with Eclipse, but I can't get past the
I'm trying create a new file with a Java Applet, but I don't know
I'm trying create this function such that if any key besides any of the
I'm trying create a gantt chart with highcharts and I need to put the
I am trying create alert dailog using glade,but its not working .am i doing
I am trying create a new css for shaping my detailsview. But i couldn't

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.