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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:12:47+00:00 2026-05-12T23:12:47+00:00

It looks like callback function is executed right after animate is called, not at

  • 0

It looks like callback function is executed right after animate is called, not at the end of the duration which that animate is set to. And it looks like it does not matter where the function is executed within or referenced.

is there a way to specify to fire up callback function at the end of duration, or i need to initiate a timer which would be set to the same value as the duration of the animation?

another thing, hypothetically, i would like same function to animate either fade in or fade out depending on css property value, the only thing that holds the entire idea smoothly going through is the fact that i can not invoke same animate on the element while animate is running. Any way to stop execution of the animate?

So far nothing in documentation, wondering if anyone had same problem and how you solved it.

Thank you in advance.

  • 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-12T23:12:48+00:00Added an answer on May 12, 2026 at 11:12 pm

    Sorry, but your looks like statements are false: the callback executes only after the event is completed.

    From the jQuery documentation for the callback parameter:

    A function to be executed whenever the animation completes, executes once for each element animated against.

    Source

    Try the following code on your computer. If this doesn’t convince you that the docs are right, then I don’t know what will.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <title>jQuery Animate, Callback Test</title>
      </head>
      <body>
        <script type="text/javascript"
          src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
        <script type="text/javascript">
          $(function() {
            $('<div id="mytest">Incoming!</div>')
              .appendTo(document.body)
              .css('font-size', '14px')
              .animate({ fontSize: '42px' }, 1500, 'linear', function() {
                $(this).text('Boom!').css('color', 'red');
              });
          });
        </script>
      </body>
    </html>
    

    The text will get bigger, then say “boom!” and turn red when the animation is complete.


    The animation will proceed without stopping by default because there is a queue. A queue is simply a list of pending animations that jQuery cycles through until it is empty. To forgo the queue, you need to use one of the overloaded versions of animate:

    $(this).animate({
      opacity: 1.0,
      width: '234px'
    }, {
      queue: false, // This skips the queue
      duration: 'fast',
      complete: function() { alert('the callback'); } // Your callback goes here...
    });
    

    Also, named functions must be passed without the parenthesis (the surrounding curly marks of this fragment) or else the function will be executed.

    var temp = myFunc(); // gets called and the result is assigned...
    var temp = myFunc;   // but this doesn't get called, and the function is passed.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 229k
  • Answers 229k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Most systems have readline installed, so I don't see that… May 13, 2026 at 1:48 am
  • Editorial Team
    Editorial Team added an answer Note 4.5 years later: this is bad advice. See one… May 13, 2026 at 1:48 am
  • Editorial Team
    Editorial Team added an answer In PHP you do not need to initialize a variable… May 13, 2026 at 1:48 am

Related Questions

I've written a Javascript script that automatically resizes the height of an IFrame, depending
I find this excellent code, posted by aemkei as answers to this questions: How
Hopefully this example will illustrate my point better than simply trying to explain it:
I am creating a simple UI toolbar component in Haxe for use in a
I have a need to be able to have a super class execute callbacks

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.