Simultaneous versus queued effects
The .animate()
method, as
we've just discovered, is very useful for creating simultaneous effects affecting a particular set of elements. There may be times, however, when we want to queue our
effects to have them occur one after the other.
Working with a single set of elements
When applying multiple effects to the same set of elements, queuing is easily achieved by chaining those effects. To demonstrate this queuing, we'll revisit Listing 4.17 by moving the Text Size box to the right-hand side, increasing its height and border width. This time, however, we perform the three effects sequentially simply by placing each in its own .animate()
method and chaining the three together:
$(document).ready(function() { ...
Get Learning jQuery - Fourth Edition 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.