.queue() (since jQuery 1.2) shows, adds to, or replaces the function queue on matched elements. The default queue name is "fx" — the effects pipeline used by .animate(), .fadeIn(), and similar methods.
Syntax
Start with these common calls. Keep them short and readable.
Element slides up
Then status: "Animation complete."
Same timing as slideUp(function () { … })
How It Works
Effect.slideUp() runs with no complete handler.
Queue. The next statement appends a function to fx.
Order. That function waits until slideUp finishes.
Frequently Asked Questions
.queue() shows, adds to, or replaces the function queue on matched elements. With no callback or array it returns an Array of pending functions. With a callback it appends that function. With an array it replaces the entire queue contents.
1) .queue([queueName]) — returns Array (default queueName "fx"). 2) .queue([queueName], callback) — adds a function; returns jQuery; callback receives next() since 1.4. 3) .queue([queueName], newQueue) — replaces the queue with an Array (e.g. [] to empty it).
"fx" is jQuery’s default effects queue. Methods like .slideUp(), .fadeIn(), and .animate() push steps onto fx and run them one at a time. Chaining $("#foo").slideUp().fadeIn() runs slideUp first; fadeIn waits until slideUp finishes.
When jQuery runs a function you added with .queue(fn), it pauses until you signal completion. Call $(this).dequeue() or the next() argument so the following step can run. Without that signal, the chain stalls.
.queue(fn) adds a standalone step at the end of the queue — useful when the previous method has no callback parameter. An animate/slideUp callback runs when that specific animation completes. Both can sit mid-chain; .queue() works with any chained method.
It replaces the fx queue with an empty array, removing all pending functions that have not yet run. Pair with .stop() to also halt the current effect. .clearQueue() is a dedicated API for clearing pending items.