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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:50:17+00:00 2026-05-25T14:50:17+00:00

Check out this fiddle: http://jsfiddle.net/mattball/nWWSa/ var $lis = $(‘ul.innerfade > li’); function fadeThemOut() {

  • 0

Check out this fiddle: http://jsfiddle.net/mattball/nWWSa/

var $lis = $('ul.innerfade > li');

function fadeThemOut()
{
    $lis.fadeOut('slow', fadeThemIn);
}

function fadeThemIn()
{
    $lis.fadeIn('slow', fadeThemOut);
}

// kick it off
fadeThemOut();

The fading in/out works fine a couple of times, but then starts going very slow. What is the problem? Is this a bug?

  • 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-25T14:50:18+00:00Added an answer on May 25, 2026 at 2:50 pm

    The problem is that the callbacks are executed for each element once it is faded in/out, not only when all of them are. So this accumulates a lot of callbacks. It goes like this (lets say we have only two elements, A and B):

    At the beginning, the queues are empty:
    A: []
    B: []

    Then you call fadeOut on both elements:
    A: [fadeOut]
    B: [fadeOut]

    A fades out: fadeIn is added to both elements.
    A: [fadeIn]
    B: [fadeOut, fadeIn]

    Then B fades out: Again, fadeIn is added to both elements.
    A: [fadeIn, fadeIn]
    B: [fadeIn, fadeIn]

    A fades in: fadeOut is added to both elements.
    A: [fadeIn, fadeOut]
    B: [fadeIn, fadeIn, fadeOut]

    B fades in: …
    A: [fadeIn, fadeOut, fadeOut]
    B: [fadeIn, fadeOut, fadeOut]

    And so forth. The exact order might differ, but as animations are queued by default, this adds more and more callbacks to the queue.

    You can solve this using deferred objects:

    $.when($lis.fadeOut('slow')).then(fadeThemIn);
    

    DEMO

    Now, fadeThemIn is only called when the animation of all elements is completed.


    Another way would be to change the functions to not work on all elements, but only on the current one:

    var $lis = $('ul.innerfade > li');
    
    function fadeThemOut()
    {
        $(this).fadeOut('slow', fadeThemIn);
    }
    
    function fadeThemIn()
    {
        $(this).fadeIn('slow', fadeThemOut);
    }
    
    // kick it off
    fadeThemOut.call($lis);
    

    though it could be that the elements are not in sync then.

    DEMO

    In your specific case, you could just fade in and out the ul element.

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

Sidebar

Related Questions

If you check out this JS fiddle: http://jsfiddle.net/DE5Bp and try to sort the Tariff
Check out this fiddle: http://jsfiddle.net/sajYc/ The transition for the :after pseudo element works in
Please check out this fiddle: http://jsfiddle.net/dppJw/8/ I've used a pseudo-element for the body (also
Please check out this http://jsfiddle.net/karthik64/JHVDn/1/ . Well I believe you got where I am
http://jsfiddle.net/4UbKe/3/ Please check out the fiddle to see exactly why it doesn't work. I'm
In this fiddle http://jsfiddle.net/SySRb/105/ , function init(); successfully checks for the existence of an
Check out this piece of JavaScript code: (function (w, d) { var loader =
Check out this code sample from Scott Guthrie's blog: http://weblogs.asp.net/blogs/scottgu/image_43366964.png Notice item is a
Please have a look at this fiddle: http://jsfiddle.net/mrmartineau/53fkV/embedded/result/ The intended outcome is that when
I used this script to create a jQuery accordion. Check out the working jsFiddle

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.