Time for action – keeping the queue running

  1. Change the <script> element at the bottom of the queueAdd.html so that it appears as follows (new code is shown in bold):
    $("#fader").fadeOut(function() {
    
      $(this).queue(function(next) {
        $(this).css("backgroundColor", "green");
        next();
      }).fadeOut();
    
    }).fadeIn().fadeOut().fadeIn();
  2. Save this file as queueInsert.html.

What just happened?

This time we have chained an extra call to the fadeout() method to the end of the queue() method inside the callback function for the first fadeout() method. We still pass an anonymous function to the queue() method, but this time we supply an argument to this function as well.

The argument we supply to the function passed into the queue() method is called next. jQuery ...

Get jQuery 1.4 Animation Techniques Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.