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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:05:43+00:00 2026-05-26T00:05:43+00:00

I have a question about animation queues in jQuery. Let’s talk over an example.

  • 0

I have a question about animation queues in jQuery. Let’s talk over an example.

Let say I have a div and a bunch of p elements in it and some of those p elements has class like “read”:

<div class="wrapper">
    <div class="inner">
        <p>Paragraph 1</p>
        <p class="read">Paragraph 2</p>
        <p>Paragraph 3</p>
        <p class="read">Paragraph 4</p>
        <p>Paragraph 5</p>
        <p class="read">Paragraph 6</p>
        <p>Paragraph 7</p>
        <p class="">Paragraph 8</p>
    </div>
</div>

I’d like to fade the read ones out and animate the height of the wrapping div element accordingly. This jQuery code block won’t work.

var initHeight = $('.wrapper').height();
$('.wrapper').height(initHeight);
$('p').not('.read').fadeOut(300, function() {
    $('.wrapper').animate({
        height: $('.inner').height()
    }, 300);
});

The reason is, after each .fadeOut our height animation will be called and as a result, div.wrapper’s height will be adjusted step by step. Here you can find the example:

http://jsfiddle.net/7gW5w/2/

So I changed the script like the one in below:

var initHeight = $('.wrapper').height();
$('.wrapper').height(initHeight);
$('p').not('.read').fadeOut(300, function() {
    if ($(this).is(':last-child')) {
        $('.wrapper').animate({
            height: $('.inner').height()
        }, 300);
    }
});

Example: http://jsfiddle.net/7gW5w/3/

In this case if we remove “read” class from the last element, it will run smoothly as I desired. However, the last p element could have “read” class. So this is not a solution either.

This is just an example to visualize my question. There can be lots of examples around. My question is, is there a method to queue my height animation, after each p element completes it’s own fadeOut animation. Hypothetical syntax:

var initHeight = $('.wrapper').height();
$('.wrapper').height(initHeight);
$('p').not('.read').fadeOut(300);
$('p').not('.read').queueAfter(function() {
    $('.wrapper').animate({
        height: $('.inner').height()
    }, 300);
});

So that after all p element completes its fadeOut animation, my height animation will be triggered.

I hope I could make my self clear.

Thanks in advance.

Ugur

  • 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-26T00:05:44+00:00Added an answer on May 26, 2026 at 12:05 am

    good question.

    i think you can solve your problem using the :last selector. my idea was to only provide a callback for the last element. like this:

    $('p').not('.read').filter(':not(:last)').fadeOut(300);
    $('p').not('.read').filter(':last').fadeOut(300, function() {
        if ($(this).is(':last-child')) {
            $('.wrapper').animate({
                height: $('.inner').height()
            }, 300);
        }
    });
    

    but I dont know how something like queueAfter could be achieved

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

Sidebar

Related Questions

I have theoretical question about OSGi memory management. Let’s say we have some OSGi
This question is similar to this one about animation queues , but the answers
I have a basic question about starting a frame-by-frame animation. When I call the
I have question about 301 Redirect please: example: http://stackapp.com/post/35642 to: http://google.com/posts/index.php?q=http://stackapp.com/post/35642 Note: I want
i have question about how to count matched elements in ArrayList in java.. Ex:
I have question about NSView: Imagine a Custom View where the mouseDown, mouseDrag and
I have a question about using streams in .NET to load files from disk.
I have a question about best practices regarding how one should approach storing complex
I have a question about locking. This doesn't have to be only about record
I have a question about how to deploy WPF application into a PC without

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.