jQuery .dequeue() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Utilities

Definition

jQuery.dequeue(element [, queueName]) (alias $.dequeue) removes the next function from an element’s queue and runs it (added in jQuery 1.3). Default queue name is "fx".

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$.dequeue(element [, queueName])  → undefined

// Inside a custom .queue() step:
.queue(function () {
  $(this).toggleClass("done");
  $.dequeue(this);          // continue the fx queue
})

// Everyday alternative:
$(this).dequeue()
// or modern:
.queue(function (next) { …; next(); })
CallWhat it does
jQueryLearn jQuery.dequeue(): run the next function on an element's fx or custom queue, finish .queue() steps with $.dequeue(this), compare with .dequeue() and next(), examples, and FAQs.

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Build a chain with .animate() / .fadeOut() and a custom .queue() step.
Step 2Inside that step, do your work (toggleClass, change text, etc.).
Step 3Call $.dequeue(this) (or $(this).dequeue() / next()) to continue.

Return Value

Return ValueDescription
jQuery objectMost setters and traversing helpers return the jQuery collection so you can chain more methods.
Value / undefinedGetters usually return a value from the first matched element, or undefined when nothing applies.

jQuery Examples

Example 1 — Official Pattern: Finish a Queue Step

Do work in .queue(), then call $.dequeue(this) so the chain continues.

jQuery
$("#box")
  .fadeOut(400)
  .queue(function () {
    $(this).text("Mid step");
    $.dequeue(this);
  })
  .fadeIn(400);
Try It Yourself

How It Works

  1. Fade out. First fx step hides the element.
  2. Custom step. Your queued function changes the text.
  3. Continue. $.dequeue(this) starts the next fx item.

Example 2 — Missing Dequeue Stalls the Chain

Without a continue signal, later effects never run.

jQuery
// Stalls — fadeIn never runs:
$("#a").fadeOut(300).queue(function () {
  $(this).text("stuck");
  // forgot $.dequeue(this);
}).fadeIn(300);

// Fixed:
$("#b").fadeOut(300).queue(function () {
  $(this).text("ok");
  $.dequeue(this);
}).fadeIn(300);
Try It Yourself

How It Works

  1. Broken path. The queue function ends without continuing → later steps wait forever.
  2. Fixed path. $.dequeue(this) unlocks fadeIn.
  3. Symptom. Element disappears and never returns.

Example 3 — Custom Queue Name

Pass the same name to $.queue and $.dequeue.

jQuery
var el = document.getElementById("box");

$.queue(el, "tasks", function (next) {
  $(el).text("Step 1");
  setTimeout(next, 400);
});
$.queue(el, "tasks", function () {
  $(el).text("Step 2");
  $.dequeue(el, "tasks");
});

$.dequeue(el, "tasks");  // start the named queue
Try It Yourself

How It Works

  1. Named queue. "tasks" is separate from the "fx" effects queue.
  2. First step. Uses next after a short delay.
  3. Second step. Continues with $.dequeue(el, "tasks").

Frequently Asked Questions

jQuery.dequeue(element [, queueName]) removes the next function from the named queue on that DOM element and runs it. It returns undefined. Added in jQuery 1.3. Prefer $(element).dequeue(queueName) for everyday code.
Same job, different call shape. jQuery.dequeue(elem) takes a raw DOM element (or this inside a queue callback). .dequeue() is called on a jQuery collection. Official docs recommend .dequeue() day to day.
An optional string naming which queue to advance. It defaults to "fx" — jQuery’s standard effects queue used by .animate(). Pass a custom name when you built that queue with .queue("name", fn).
When jQuery runs a function you added with .queue(), the pipeline pauses until you signal completion. Call jQuery.dequeue(this), $(this).dequeue(), or next() so later animations can continue.
No useful return — the static API returns undefined. Instance .dequeue() returns the jQuery object for chaining.
Prefer .dequeue() or next() inside .queue(function(next){ ... next(); }). Use jQuery.dequeue(element) when you already hold a raw DOM node or are reading older $.dequeue(this) examples.

Next: jQuery.support Property

Learn how jQuery iterates arrays and plain objects.

jQuery.support Property tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful