jQuery :animated Selector

Beginner
5 min read
Updated: Nov 2026
3 examples
Selectors

Definition

:animated (since jQuery 1.2) matches elements that are mid-animation right now — any node with a jQuery effects queue in progress. When the effect finishes, the element stops matching.

Syntax

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

jQuery
$(":animated")                 → every animating element
$("div:animated")              → animating divs only
$("#panel div").filter(":animated")  → faster pattern

$("#box").is(":animated")      → true / false for one element
/* CSS transitions / WAAPI → not matched */
CallWhat it does
:animatedMatches elements with an active jQuery fx queue
Effects moduleWithout it, the selector throws
CSS base selectorLets native engines narrow the set first

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

Parameters

ParameterDescription
Step 1Ensure a full jQuery build with the effects module (not a slim custom build).
Step 2Start an effect such as .slideToggle(), .fadeIn(), or .animate().
Step 3Select candidates with CSS first: $("div") or $("#panel .box").

Return Value

Return ValueDescription
See examplesCheck the examples below for what this API returns in common cases.

jQuery Examples

Example 1 — Official Demo: List div:animated

While #mover loops with slideToggle, click to list which divs are mid-animation.

jQuery
$("#run").on("click", function () {
  var ids = $("div:animated").map(function () {
    return this.id || "(no id)";
  }).get().join(", ");
  console.log("animated:", ids || "(none)");
});

function animateIt() {
  $("#mover").slideToggle("slow", animateIt);
}
animateIt();
Try It Yourself

How It Works

  1. Start a loop. slideToggle with a completion callback restarts itself on #mover.
  2. Query on click. $("div:animated") is a snapshot of animating divs at that instant.
  3. Map ids. Only elements currently in the fx queue appear in the list.

Example 2 — Test One Element with .is(":animated")

Ask a single element whether it is mid-animation without scanning the whole page.

jQuery
$("#mover").slideToggle("slow");

$("#check").on("click", function () {
  console.log("#mover animated?", $("#mover").is(":animated"));
  console.log("#static animated?", $("#static").is(":animated"));
});
Try It Yourself

How It Works

  1. Animate one box. slideToggle puts #mover into the fx queue.
  2. Boolean check. .is(":animated") returns true or false for that element.
  3. Compare. #static stays false because nothing is running on it.

Example 3 — Faster Pattern: .filter(":animated")

Official performance tip: select with CSS first, then filter for animation state.

jQuery
$("#box-a, #box-b").slideToggle("slow");

$("#run").on("click", function () {
  var n = $("#demo div").filter(":animated").length;
  console.log("animating in #demo:", n);
});
Try It Yourself

How It Works

  1. CSS first. $("#demo div") can use native selector speed.
  2. Then filter. .filter(":animated") keeps only nodes with an active fx queue.
  3. Why it helps. Bare $(":animated") cannot use querySelectorAll.

Frequently Asked Questions

:animated matches every element that is actively running a jQuery animation at the exact moment the selector executes. When the animation finishes, the element no longer matches until a new effect starts.
Any element with a jQuery effects queue in progress — .slideToggle(), .fadeIn(), .show('slow'), .animate(), and similar methods from the effects module. Pure CSS transitions or Web Animations API animations are not tracked by :animated.
jQuery tracks animation state internally when effects run. A custom slim build without the effects module has no animation registry, so :animated throws an error when used.
Because :animated is a jQuery extension, not standard CSS, it cannot use the browser's native querySelectorAll speed boost. Pick elements with a pure CSS selector first, then narrow with .filter(':animated').
Yes. Combine a tag with the pseudo: $("div:animated") matches only div elements that are animating. The official demo uses $("div:animated") on a click handler.
Only while the slide is running. In a recursive slideToggle loop, the element matches during each transition and stops matching briefly when the slide completes before the next toggle starts.

Next: :button Selector — Match Buttons

Select button elements and input type="button" controls in one query.

:button Selector — Match Buttons 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