.fadeToggle() (since jQuery 1.4.4) displays or hides matched elements by animating their opacity. Visible elements fade out and get display: none; hidden elements unhide and fade in. Returns the jQuery object for chaining.
Remember
$("#panel").fadeToggle(); // default 400 ms
$("#panel").fadeToggle("slow", "linear");
$("#panel").fadeToggle("fast", function () { /* done */ });
// Visible → fade out → display:none
// Hidden → show → fade in to opacity 1
Select the element, call .fadeToggle() from a click (or other) handler, optionally pass duration, easing, or a callback.
Select the target with jQuery ($("#panel")).
On a user action, call .fadeToggle() (optional duration / easing / complete).
jQuery checks visibility and runs fade-in or fade-out.
On fade-out, display: none is set when opacity hits 0.
For spam clicks, chain .stop(true, true) before .fadeToggle().
Piece
Required?
Role
Matched set
Yes
Elements to fade in or out
duration
No
Default 400; also "fast" (200) / "slow" (600)
easing
No
Default "swing"; built-in also "linear"
complete
No
Runs once per matched element when its fade ends
Return value
—
jQuery object (chainable)
Pseudocode
Pseudocode
call $(elements).fadeToggle(duration?, easing?, complete?)
for each matched element:
if element is visible:
animate opacity → 0
set display: none
else:
restore display
animate opacity → 1
if complete was provided:
call complete once for this element
(this = the DOM element)
return the jQuery set for chaining
Reference
Cheat Sheet
Keep these facts handy while building fade toggles.
Topic
Detail
Syntax
.fadeToggle([duration] [, easing] [, complete])
Options form
.fadeToggle({ duration, easing, complete, … })
Since
jQuery 1.4.4
Default duration
400 ms
Presets
"fast" = 200 · "slow" = 600
Easing
swing (default) · linear
Callback
Once per element · use .promise() for “all done”
Rapid clicks
$el.stop(true, true).fadeToggle()
Try it
Live Preview
Click Run to fadeToggle the sample paragraph. Change duration with the chips.
This paragraph fades in or out with .fadeToggle().
Each Run toggles visibility. Reset forces the paragraph visible again.
Result
Ready — click Run to fadeToggle.
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools, or use Try It Yourself for a live editor.
Example 1 — Official Two-Button Demo
From the jQuery docs: slow linear on the first p; fast with a complete log on the last p.
jQuery
$("button").first().on("click", function () {
$("p").first().fadeToggle("slow", "linear");
});
$("button").last().on("click", function () {
$("p").last().fadeToggle("fast", function () {
$("#log").append(" finished ");
});
});
Rapid clicks no longer stack fades
stop(true, true) clears queue + jumps to end
Then fadeToggle(300) starts clean
How It Works
Problem. Each click queues another fade → flicker.
Clear. First true empties the fx queue.
Jump. Second true finishes the current tween now.
Toggle..fadeToggle() starts from a known end state.
Edge Cases & Pitfalls
Watch these when fades feel wrong or “stack.”
queue
Rapid clicks queue animations
Use .stop(true, true) before .fadeToggle() on toggle buttons users can spam.
callback
Complete runs once per element
Animating three elements fires the callback three times. Use .promise().done() for one “all finished” hook.
display
Fade-out ends at display: none
The element leaves the layout. That is intended — not the same as opacity 0 while still taking space.
fx.off
jQuery.fx.off skips animation
When true, toggles snap instantly (duration 0). Useful for reduced-motion preferences.
vs toggle
.toggle() is not a fade
.toggle() shows/hides immediately. Use .fadeToggle() when you want opacity animation.
Compatibility
Browser Support
.fadeToggle() has been part of jQuery since 1.4.4. It works in every browser that runs your loaded jQuery version — no separate browser feature flag.
✓ Stable · jQuery 1.4.4+
jQuery .fadeToggle()
Supported across jQuery 1.4.4+, 2.x, and 3.x. Prefer a current jQuery 3.x build. Opacity animation uses jQuery’s fx engine.
100%With jQuery
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
.fadeToggle()Universal
Bottom line: Safe for everyday UI toggles. Guard rapid clicks with .stop(true, true), and respect jQuery.fx.off for reduced motion.
Analysis
Performance Notes
Approach
Cost
Best for
One element fadeToggle
Cheap
Panels, menus, help boxes
Many elements at once
More paint work
Keep sets small; prefer one container
Queued spam clicks
Wasted frames
Always .stop(true, true) on toggles
Opacity fades are inexpensive for a few elements. Cost climbs with large sets or stacked queues — stop before toggle, and prefer fading one wrapper over dozens of children.
Remember
Key Takeaways
Role: animated show/hide via opacity — since jQuery 1.4.4.
Direction: from current visibility — no separate toggle flag.
Guard:.stop(true, true) before toggle on busy buttons.
One line:.fadeToggle() fades an element in or out from its current visibility — one call for both directions.
Frequently Asked Questions
.fadeToggle() shows or hides matched elements by animating opacity. If the element is visible, it fades out and sets display:none when opacity reaches 0. If hidden, it unhides and fades in to full opacity. One call replaces a manual fadeIn / fadeOut branch.
.fadeToggle() was added in jQuery 1.4.4. It shares the same duration defaults, easing support, and callback semantics as .fadeIn() and .fadeOut().
1) .fadeToggle([duration] [, easing] [, complete]) — optional duration (default 400 ms), easing (default swing), and a per-element complete callback. 2) .fadeToggle(options) — a plain object with duration, easing, queue, step, progress, complete, and Promise-style start/done/fail/always.
.fadeToggle() picks fade-in or fade-out from current visibility. .fadeIn() / .fadeOut() are one-direction only. .toggle() shows or hides instantly with no opacity animation. Use .fadeToggle() when one control should animate both directions.
Once per matched element when that element’s fade finishes — not once for the whole set. Inside the callback, this is the DOM element. Use .promise().done() when you need a single callback after every element completes.
Call .stop(true, true) before .fadeToggle(). The first true clears the fx queue; the second jumps the current animation to its end state. Then fadeToggle starts from a clean baseline.