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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:25:13+00:00 2026-06-05T05:25:13+00:00

html: <span>hello world!</span> js: (using callback) $(‘span’).click(function() { $(this).animate({ fontSize: ‘+=10px’ }, ‘slow’, function()

  • 0

html:

<span>hello world!</span>

js: (using callback)

$('span').click(function() {
  $(this).animate({
    fontSize: '+=10px'
  }, 'slow', function() {
    // callback after fontsize increased
    $(this).text(  $(this).text() + ' rolled! ' );
  });
});

So that every time SPAN is click, text ‘rolled’ appended after font size increased, instead of happening together.

And it can be done by using queue() as well like this:

js: (using queue())

$('span').click(function() {
  $(this).animate({
    fontSize: '+=10px'
  }, 'slow'})
  .queue(function() {
    $(this).text(  $(this).text() + ' rolled! ' );
  });
});

I am not sure what is the difference between them. both do the same thing.

Why is queue() better/prefer than using callback, (or why is not ) ? What is special about queue()?

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-05T05:25:16+00:00Added an answer on June 5, 2026 at 5:25 am

    You can put more events (which you specifie else in your code) in the same queue as your animation is put in.

    So the callback will be executed immediately after your animation is ready, but in case of using queue() there may be other events in the queue that will be executed first.

    The advantage of this behaviour is that no concurrent events (slide up and slide down for example) will be executed at the same time, which would give weird things.

    Example:

    $('div').click(function() {
      $(this).animate({
        color: 'green'
      }, 'slow'})
      .queue(function() {
        $(this).text( ' got colored! ' );
      });
    });
    
    $('span').click(function() {
      $(this).animate({
        fontSize: '+=10px'
      }, 'slow'})
      .queue(function() {
        $(this).text(  ' got bigger! ' );
      });
    });
    

    If you first click the div and immediately after that the span, now you can be sure that the queue of the div will be executed first, and that when it’s ready, the queue of the span will be executed.

    In case of a callback, the one belonging to the animation that is ready first, will be executed first. And if they would be ready at the same time, the would both be executed at the same time. Which would result in, in this case, not seeing either the ‘got colored!’ text or the ‘got bigger!’ text.

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

Sidebar

Related Questions

Let's say I have this portion of HTML document: <div>hello world <span id=test></span></div> In
I have this simple html: <div class=wrapper> <span class=higher> [higher] <span class=lower> hello </span>
This is the HTML: <div id=testBlue> <span>hello</span> <span id=testGreen class=testGreen>hello2</span> </div> If I have
I have the following function: function checktotal(){ total = currentproduct[priceperticket] * $(#qtyselect).val(); $(span#totalprice).html($+total); }
i have this html: <span class=price> $61.00 <span class=detailFreeShipping>With Free Shipping</span> </span> How to
I am using html to make text in a JLabel span multiple lines. However
Hello guys on my blog I use this script: jQuery(document).ready(function () { jQuery(.postbox).hover(function ()
If I've got something like: var x = <div><span>hello</span><span>world</span></div> and add it to some
How should I generate such HTML with HAML? Hello <span class=someclass>John</span>, you are welcome!
I have the following structure. <div> <p>Hello World !!</p> </div> <iframe id="myiframe" src='myiframeContent.html'></iframe> and

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.