jQuery :animated Selector

Beginner
⏱️ 9 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Effects state

What You’ll Learn

The :animated selector finds elements that are mid-animation when your query runs — slide, fade, show/hide, or custom .animate() effects. This tutorial covers the official jQuery demo, performance tips with .filter(), timing pitfalls, and when :animated does not apply.

01

Syntax

$(":animated")

02

Timing

Live snapshot

03

Effects

jQuery queue only

04

Combine

div:animated

05

Performance

.filter()

06

Since 1.2

Extension

Introduction

Most jQuery selectors describe what an element is — a tag, class, or ID. The :animated pseudo-class describes what an element is doing right now: running a jQuery animation. Added in jQuery 1.2, it is one of several jQuery-specific extensions that do not exist in standard CSS.

Think of it as a snapshot. When you run $(":animated"), jQuery checks its internal animation registry and returns every element with an active effect. A moment later, when the animation completes, that same query may return nothing. This makes :animated perfect for debugging motion, highlighting moving panels, or guarding UI actions while transitions are in flight.

Understanding the :animated Selector

An element is animated in jQuery terms when a method from the effects module has started a transition and not yet reached its completion callback. That includes .slideToggle(), .fadeIn(), .hide("slow"), and .animate({ ... }).

Pure CSS transition or @keyframes animations do not register with jQuery — :animated will not find them. Likewise, a custom jQuery build stripped of the effects module cannot support this selector at all and will throw an error if you try.

💡
Beginner Tip

Click Run in the official demo while #mover is sliding — only then does $("div:animated") match and turn green. Click again when the div is still and nothing happens visually.

📝 Syntax

Official jQuery API form (since 1.2):

jQuery
jQuery( ":animated" )
// shorthand:
$( ":animated" )

// combine with element types:
$( "div:animated" )

Parameters

  • :animated — no arguments; matches elements with a jQuery effect currently in progress.

Return value

  • A jQuery object containing zero or more animating elements at query time.
  • Empty collection when no animations are running.

Recommended performance pattern

  • $( "#stage div" ).filter( ":animated" ) — CSS selector first, then jQuery filter.
  • $( "div:animated" ) — shorthand tag + pseudo-class combo.
  • $( ":animated" ).length — quick count of active animations.

Official jQuery API example

jQuery
$( "#run" ).on( "click", function() {
  $( "div:animated" ).toggleClass( "colored" );
});

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

⚡ Quick Reference

GoalCode
All animating elements$(":animated")
Animating divs only$("div:animated")
Scoped + performant$("#panel div").filter(":animated")
Count active animations$(":animated").length
Stop every animation$(":animated").stop(true, true)
CSS transitionsNot matched by :animated

📋 $(":animated") vs .filter(":animated")

Both find animating elements — scoping with a CSS selector first is faster on large pages.

Global
$(":animated")

Every animating node on page

Tag combo
$("div:animated")

Official demo pattern

Filter
.filter(":animated")

Docs recommend this

Not matched
CSS @keyframes

jQuery queue only

Examples Gallery

Example 1 follows the official jQuery API demo. Examples 2–5 cover looping animations, performance filtering, timing checks, and stopping all motion. Use the Try-it links to run each snippet in the browser.

📚 Official jQuery Demo

Toggle a green class on any div that is animating when you click Run.

Example 1 — Official Demo: Toggle Class on div:animated

A div slides up and down forever. Click Run while it moves to add or remove the colored class on animating divs.

jQuery
$( "#run" ).on( "click", function() {
  $( "div:animated" ).toggleClass( "colored" );
});

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

How It Works

animateIt() calls slideToggle("slow", animateIt), re-queueing itself when each slide finishes. On Run click, jQuery scans for divs with active effects — only #mover during motion — and toggles colored.

Example 2 — Recursive slideToggle Explained

Break down the loop so you see when :animated is true vs false.

jQuery
function animateIt() {
  $( "#mover" ).slideToggle( "slow", function() {
    // Callback runs when slide FINISHES — no longer :animated here
    console.log( "Finished. Animated count:", $( ":animated" ).length );
    animateIt(); // start next toggle
  });
}

animateIt();

// During the slide (before callback): $( ":animated" ).length === 1
Try It Yourself

How It Works

:animated reflects instantaneous state. Between animations the count drops to zero even though the loop continues — timing matters when you query.

📈 Practical Patterns

Performance filtering, timing guards, and emergency stops.

Example 3 — Performance: .filter(":animated")

Official docs recommend selecting with CSS first, then filtering — especially inside a large container.

jQuery
// Prefer this on big pages:
$( "#stage" ).find( "div" ).filter( ":animated" ).addClass( "busy" );

// Instead of scanning the entire document:
// $( ":animated" ).addClass( "busy" );
Try It Yourself

How It Works

:animated is a jQuery extension — browsers cannot accelerate it with native querySelectorAll. Narrow the candidate set with standard CSS selectors first.

Example 4 — Check :animated During vs After fadeIn

Log counts immediately after starting an effect and inside the completion callback.

jQuery
$( "#box" ).fadeIn( 800 );

console.log( "Right after fadeIn call:", $( "#box" ).filter( ":animated" ).length );

$( "#box" ).promise().done( function() {
  console.log( "After fade completes:", $( "#box" ).filter( ":animated" ).length );
});
Try It Yourself

How It Works

fadeIn enqueues an effect immediately, so the first log shows 1. When the fade finishes, jQuery clears animation state and :animated no longer matches.

Example 5 — Stop All Animations with $(":animated").stop()

Emergency brake: halt every running jQuery effect before starting new ones.

jQuery
$( "#stop-all" ).on( "click", function() {
  $( ":animated" ).stop( true, true );
  $( "div" ).removeClass( "colored busy" );
});

// stop(clearQueue, jumpToEnd)
// true, true — clear queued effects and snap to final state
Try It Yourself

How It Works

.stop(true, true) clears the effects queue and jumps to the end state. After stopping, $(":animated") returns an empty set until a new animation starts.

🚀 Common Use Cases

  • Debug dashboards — highlight $(":animated") during QA to spot runaway loops.
  • Disable buttons — block submits while $("#form").find(":animated").length is greater than zero.
  • Carousel guards — ignore next/prev clicks when slides are mid-transition.
  • Batch styling — add a busy class to animating cards for visual feedback.
  • Cleanup on route change$(":animated").stop(true, true) before SPA navigation.
  • Teaching effects — official demo pattern for showing live animation state.

🧠 How jQuery Resolves :animated

1

Effect starts

A method like slideToggle registers the element in jQuery’s animation tracker.

Queue
2

Query runs

:animated checks which tracked elements are still in progress right now.

Snapshot
3

Return matches

Matched nodes become a jQuery object for chaining .toggleClass(), .stop(), etc.

Collection
4

Effect ends

On completion, jQuery removes the element from the animated set — next query may return zero matches.

📝 Notes

  • Available since jQuery 1.2 — a jQuery extension, not standard CSS.
  • Requires the effects module — slim custom builds throw without it.
  • Does not detect CSS transition or animation properties.
  • Matches only at query time — asynchronous; re-query if you need updated state.
  • Official performance tip: CSS selector first, then .filter(":animated").
  • Works with chained effects — an element stays animated until its current step completes.

Browser Support

The :animated selector ships with jQuery 1.2+ and the standard effects module. Browser compatibility follows your jQuery version — the selector itself has no separate native CSS support because it is a jQuery invention.

jQuery 1.2+ · Effects module

jQuery :animated Selector

Works wherever full jQuery with effects runs — all modern browsers and legacy IE with supported jQuery builds. Not available in querySelectorAll or in slim jQuery builds without effects.

100% With jQuery + effects
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
:animated Universal

Bottom line: Load full jQuery (not a slim effects-stripped build). For modern apps consider CSS transitions with class toggles — :animated is most useful when you already rely on jQuery effects.

Conclusion

The jQuery :animated selector finds elements with active jQuery effects — a live snapshot, not a permanent property. The official demo pairs it with a looping slideToggle and a Run button that toggles colored on moving divs.

Remember the docs’ performance note: scope with CSS selectors, then .filter(":animated"). Skip it for CSS-only motion, and never use it in builds missing the effects module.

💡 Best Practices

✅ Do

  • Use $("#container div").filter(":animated") on large pages
  • Query while you know an effect is running (mid-click, in callbacks)
  • Pair with .stop() to cancel runaway animation loops
  • Include the full jQuery effects module in your build
  • Combine with element types: $("div:animated")

❌ Don’t

  • Expect :animated to detect CSS keyframe animations
  • Run $(":animated") on every mousemove — it is a live scan
  • Use slim jQuery builds without the effects module
  • Assume zero results means animations are broken — they may be between cycles
  • Rely on :animated in new projects that use CSS transitions only

Key Takeaways

Knowledge Unlocked

Five things to remember about :animated

Live snapshot of jQuery motion.

5
Core concepts
02

Snapshot

Not permanent

Timing
03

.filter()

Performance

Scope
🎨 04

Effects

jQuery queue

Module
05

Not CSS

No @keyframes

Limit

❓ 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 normal CSS selector first, then narrow with .filter(':animated').
Yes. Combine tag names with the pseudo-class: $('div:animated') matches only div elements that are animating. The official demo uses $('div:animated').toggleClass('colored').
Only while the slide animation is running. In the official recursive slideToggle demo, #mover matches during each transition and stops matching when the slide completes and before the next toggle begins.
Did you know?

jQuery also provides :hidden, :visible, and :focus — sibling extension selectors that, like :animated, work inside jQuery but not in native querySelectorAll.

Continue to [attr|=value]

Learn how to match language codes and hyphenated attribute prefixes.

Attribute prefix tutorial →

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.

6 people found this page helpful