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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:33:08+00:00 2026-06-12T05:33:08+00:00

Adding a sequence of animations to a single dom element using jQuery is extremely

  • 0

Adding a sequence of animations to a single dom element using jQuery is extremely easy. jQuery queues everything up nicely for me and I basically don’t have to do anything.

However making a sequence of animations over a number of elements (eg pictureDiv fades out, then demographicsDiv fades in) is much harder. I’ve written a plugin type thing to make it easier as below:

var something.createAnimationQueue = function () {

    // jQuery queues up animations on each dom element (/ jquery object)
    // We want to queue up animations over different dom elements so 
    // use a jquery object on a blank element
    var animationQueue = $({});

    return {
        add: function (animationFunctionContext, animationFunction) {
            var args = $.makeArray(arguments).slice(2);
            animationQueue.queue(function (next) {
                $.when(animationFunction.apply(animationFunctionContext, args)).done(next)
            })
        }
    }
}

Which is used thusly

        var animationQueue = something.createAnimationQueue();

        animationQueue.add(pictureDiv, pictureDiv.fadeOut, 'slow');
        animationQueue.add(demographicsDiv, demographicsDiv.fadeIn, 'slow');

My questions are:

1) Have I missed something? Is there an easier way of doing this that I didn’t know about.

2) If not, is there a way to avoid passing pictureDiv and pictureDiv.fadeOut to the animationQueuer? (I tried and couldn’t think of one)

Thanks!

  • 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-12T05:33:09+00:00Added an answer on June 12, 2026 at 5:33 am

    Since you are using .apply and reassigning this, you could simply use

    var animationQueue = something.createAnimationQueue();
    
    animationQueue.add(pictureDiv, $.fn.fadeOut, 'slow');
    animationQueue.add(demographicsDiv, $.fn.fadeIn, 'slow');
    

    And if you really wanted to, you could turn that into a string:

    var something.createAnimationQueue = function () {
    
        // jQuery queues up animations on each dom element (/ jquery object)
        // We want to queue up animations over different dom elements so 
        // use a jquery object on a blank element
        var animationQueue = $({});
    
        return {
            add: function (animationFunctionContext, method) { // <----
                var args = $.makeArray(arguments).slice(2);
                animationQueue.queue(function (next) {
                    $.when($.fn[method].apply(animationFunctionContext, args)).done(next) // <----
                })
            }
        }
    }
    
    var animationQueue = something.createAnimationQueue();
    
    animationQueue.add(pictureDiv, 'fadeOut', 'slow'); // <----
    animationQueue.add(demographicsDiv, 'fadeIn', 'slow'); // <----
    

    Note, however, this can’t be used for more than just animations now. You could use this with any jQuery method that returns a promise object, such as .ajax, .post, .get, .getJSON, etc. if you used it like you originally had it.

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

Sidebar

Related Questions

I'm using a integer sequence of values in highcharts, but it's adding .00 after
When I run the following jQuery animation sequence: $('#task').animate({ backgroundColor: fadeColor }, 50) .animate({
Is there any auto increment property for field in Oracle without using sequence and
First of all, I don't have multiplication, division operations so i could use shifting/adding,
Here is a command sequence showing distinct svn diff behaviours for adding versus copying
Each new term in the Fibonacci sequence is generated by adding the previous two
I have a little issue on what sequence things are being called when adding
Currently, I'm adding elements to my XmlDocument using XPath notation for which I've written
Using event handlers in my Site-scoped feature's Feature Receiver, I'm adding my HttpHandler to
The WSDL looks like this: <xsd:element name=Parent> <xsd:complexType> <xsd:sequence> <xsd:element maxOccurs=unbounded ref=tns:Child/> </xsd:sequence> </xsd:complexType>

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.