The .fadeTo() instance method adjusts the opacity of matched elements to a specific value between 0 and 1. This tutorial covers both overloads since jQuery 1.0 (including easing since 1.4.3), the required duration parameter, per-element callbacks, comparisons with .fadeIn(), .fadeOut(), .animate({ opacity }), and .css("opacity"), and five hands-on examples from the official jQuery API plus a dim overlay pattern.
01
Target opacity
Any value 0–1
02
Duration
Required, not optional
03
Two overloads
Positional + easing
04
No display
Never hides or unhides
05
Callbacks
Once per element
06
fx queue
Chain with other effects
Fundamentals
Introduction
Sometimes you do not want a full reveal or a complete hide — you want something in between. A modal backdrop at 40% opacity, a photo dimmed to half strength, or a quiz answer fading to 25% so the correct choice stands out. For those cases, .fadeTo() is jQuery’s dedicated opacity tweener.
Available since jQuery 1.0, .fadeTo() animates the opacity CSS property toward the number you pass. Unlike .fadeIn() and .fadeOut(), it never changes display. The element stays visible (or hidden) exactly as it was — only its transparency changes. It enqueues on the default fx queue like other effects, so you can chain it with .fadeIn(), .delay(), or another animation for polished sequential choreography.
Concept
Understanding the .fadeTo() Method
Per the official jQuery API, .fadeTo() adjusts the opacity of the matched elements. It is similar to .fadeIn(), but that method unhides the element and always fades to 100% opacity. .fadeTo() lets you pick any target opacity and leaves display untouched.
Durations are given in milliseconds; higher values indicate slower animations. The strings "fast" (200 ms) and "slow" (600 ms) work as presets. Unlike other effect methods, .fadeTo() requires that duration be explicitly specified — there is no default 400 ms shortcut.
💡
Beginner Tip
Think of .fadeTo() as the precision dial between .fadeIn()’s full reveal and .fadeOut()’s complete exit. You choose the exact opacity level and the element stays in layout.
duration (Number or String, required) — milliseconds, or "fast" (200) / "slow" (600). No default when omitted.
opacity (Number, required) — a number between 0 and 1 denoting the target opacity (e.g. 0.5 = 50%).
easing (String, default "swing", since 1.4.3) — built-in swing or linear; plugins add more.
complete (Function) — called once per matched element when that element’s fade finishes. this is the DOM element.
Return value
A jQuery object for chaining further queued methods on the same set.
Official jQuery API description
jQuery
// With the element initially shown, we can dim it slowly:
$( "#clickme" ).on( "click", function() {
$( "#book" ).fadeTo( "slow", 0.5, function() {
// Animation complete.
});
});
📋 .fadeTo() vs fadeIn vs fadeOut vs .animate({ opacity }) vs .css("opacity")
Five ways to change opacity — only .fadeTo() animates to an exact level without touching display.
.fadeTo()
$el.fadeTo(400, 0.5)
Animates to a specific opacity between 0 and 1 — element stays in current display state
.fadeIn()
$el.fadeIn("slow")
Unhides hidden elements and fades to full opacity — preset reveal shorthand
.fadeOut()
$el.fadeOut("slow")
Fades visible elements to transparent then sets display:none — preset exit shorthand
.animate({ opacity })
.animate({ opacity: 0.5 }, 400)
Generic opacity tween — same visual result but no required-duration shorthand semantics
.css("opacity")
$el.css("opacity", 0.5)
Instant opacity change with no animation — equivalent to .fadeTo(0, 0.5)
Hands-On
Examples Gallery
Each example demonstrates an official jQuery API .fadeTo() pattern or a common real-world use case. Open DevTools or use the Try-it links. Examples 1–4 mirror live demos on api.jquery.com/fadeTo/.
📚 Getting Started
Official jQuery API demos — basic click-to-dim and partial paragraph fade patterns.
Example 1 — Basic Usage: Visible #book fadeTo("slow", 0.5) on Click
With the element initially shown, click #clickme to dim #book to 50% opacity over the slow preset (600 ms) with a completion callback.
jQuery
// With the element initially shown, we can dim it slowly:
$( "#clickme" ).on( "click", function() {
$( "#book" ).fadeTo( "slow", 0.5, function() {
// Animation complete.
});
});
#book starts fully visible; click dims it to 50% opacity over 600ms — element stays in layout
How It Works
.fadeTo("slow", 0.5) maps to 600 milliseconds. jQuery tweens opacity from its current value toward 0.5. Display is never changed, so the element remains visible at half strength.
Example 2 — First Paragraph fadeTo("slow", 0.33) on Click (Official Example 1)
Click the first paragraph to fade it to 33% opacity (about one third visible) over the slow preset. The second paragraph stays at full opacity for comparison.
Click first paragraph: it fades to 33% opacity over 600ms; second paragraph unchanged
How It Works
Only the clicked paragraph is targeted via $(this). The opacity value 0.33 is a fractional target — not a percentage. The element stays displayed; only transparency changes.
📈 Advanced Patterns
Random opacity tweens, callback styling, and modal backdrop dimming.
Example 3 — Stacked Divs fadeTo("fast", Math.random()) on Click (Official Example 2)
Click any stacked div to fade it to a random opacity between 0 and 1 over the fast preset (200 ms).
Each click tweens the clicked div to a random opacity over 200ms — stacked colors shift unpredictably
How It Works
Math.random() returns a float between 0 and 1, making each click produce a different target opacity. Because .fadeTo() never hides elements, even low values leave the div visible (just very transparent).
Example 4 — Quiz Divs fadeTo(250, 0.25) Callback Styles Previous Sibling (Official Example 3)
Click a quiz answer div to fade it to 25% opacity over 250 ms. In the callback, style the previous sibling paragraph with bold italic text to highlight the correct answer.
Clicked answer div fades to 25% over 250ms; callback bold-italicizes the preceding paragraph label
How It Works
The complete callback runs after opacity reaches 0.25. Inside it, this refers to the faded div. Chaining .prev() selects the label paragraph above it for styling — a pattern for de-emphasizing wrong answers while highlighting the right one.
Example 5 — Dim Modal Backdrop fadeTo(600, 0.4) Without Hiding Element
Open a modal by fading the backdrop overlay to 40% opacity over 600 ms. Unlike .fadeOut(), the backdrop stays in the DOM and layout at partial transparency — ready to fade back to full opacity when the modal closes.
jQuery
// Show modal — dim backdrop without hiding it
$( "#open-modal" ).on( "click", function() {
$( "#backdrop" ).show().fadeTo( 600, 0.4 );
$( "#modal" ).fadeIn( 400 );
});
// Close modal — restore backdrop to full opacity, then hide
$( "#close-modal" ).on( "click", function() {
$( "#modal" ).fadeOut( 300 );
$( "#backdrop" ).fadeTo( 400, 0, function() {
$( this ).hide();
});
});
Backdrop fades to 40% opacity over 600ms while staying visible; modal fades in. Close reverses with fadeTo(400, 0) then hide.
How It Works
.fadeTo() is ideal for overlays because it dims without setting display: none. Pair with .fadeIn() for the modal panel and use .fadeTo(400, 0) in the close path before calling .hide() in the callback when you need the element fully transparent and removed from layout.
Applications
🚀 Common Use Cases
Modal backdrops — dim overlay panels to 30–50% opacity while keeping them clickable and in layout.
De-emphasizing content — fade inactive sections to partial opacity during focus modes or guided tours.
Interactive quizzes — fade wrong answers to low opacity and style correct labels in the callback.
Hover and focus states — tween images or cards to a softer opacity on interaction without hiding them.
Cross-fade prep — dim the current slide before swapping content, then .fadeTo(400, 1) to restore.
Effect chains — combine with .delay() and .fadeIn() for layered show/dim choreography on the fx queue.
🧠 How .fadeTo() Adjusts Opacity
1
Duration and target set
You pass a required duration and an opacity value between 0 and 1. jQuery reads the element’s current opacity as the starting point.
Input
2
Opacity animates toward target
jQuery tweens the opacity CSS property from its current value toward your target over the chosen duration and easing curve.
Tween
3
Display stays unchanged
Unlike .fadeIn() or .fadeOut(), .fadeTo() never sets display. The element remains visible or hidden as it was before the call.
No display
4
▶
Target opacity and callback
Element ends at the specified opacity. complete fires once per matched element; fx queue advances to the next step.
Important
📝 Notes
Available since jQuery 1.0; easing overload added in 1.4.3.
duration is required — unlike .fadeIn() and .fadeOut(), there is no default 400 ms when omitted.
opacity must be a number between 0 and 1 (e.g. 0.5 for 50%).
With duration set to 0, .fadeTo(0, opacity) is equivalent to .css("opacity", opacity).
Does not unhide elements or set display: none — only the opacity property changes.
Callbacks fire once per matched element — use .promise().done() for one set-level callback.
Set jQuery.fx.off = true globally to disable all effects including .fadeTo() (duration becomes 0).
Compatibility
Browser Support
.fadeTo() is a jQuery instance method since 1.0+. It uses jQuery’s internal fx engine and opacity tweens — behavior is consistent wherever jQuery runs, independent of CSS transition support.
✓ Stable · jQuery 1.0+
jQuery .fadeTo()
Supported in all jQuery 1.x, 2.x, 3.x, and 4.x releases. Works in Chrome, Firefox, Safari, Edge, IE 6+ (with compatible jQuery builds), and Node.js via jsdom.
100%jQuery fadeTo API support
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
.fadeTo()Universal
Bottom line: Learn .fadeTo() alongside .fadeIn(), .fadeOut(), and .queue() to build polished opacity and effect sequences in legacy and modern jQuery apps.
Wrap Up
Conclusion
The .fadeTo() method is jQuery’s shorthand for animating matched elements to a specific opacity between 0 and 1. Two overloads cover simple duration-plus-opacity calls and easing since 1.4.3.
Always pass an explicit duration, pick your target opacity, and remember that display is never touched. Use the complete callback to chain follow-up styling or enqueue the next effect. Pair this method with .fadeOut() behind you and .queue() ahead to master the full fx pipeline.
Always pass an explicit duration — it is required for .fadeTo()
Use fractional opacity values between 0 and 1 (e.g. 0.4 for 40%)
Choose .fadeTo() for partial transparency overlays and dim states
Use the complete callback to style siblings or enqueue the next effect
Call .promise().done() when you need one callback after all elements finish
❌ Don’t
Expect .fadeTo() to hide elements — use .fadeOut() for that
Expect .fadeTo() to unhide elements — call .show() or .fadeIn() first
Omit duration thinking a 400 ms default applies — only .fadeIn() / .fadeOut() have that default
Assume one callback covers the whole set — it fires per matched element
Pass percentage values like 50 instead of 0.5 — opacity is 0–1, not 0–100
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about .fadeTo()
Shorthand for animating to an exact opacity level.
5
Core concepts
🌟01
Target opacity
Any value 0–1
Core
⏱02
Duration required
No 400 ms default
API
🔄03
No display change
Never hides/unhides
Behavior
📝04
Per-element cb
Not once per set
Callback
⚡05
fadeTo(0, n)
Equals .css opacity
Instant
❓ Frequently Asked Questions
.fadeTo() adjusts the opacity of matched elements to a specific value between 0 and 1. It animates the opacity CSS property over the duration you supply. Unlike .fadeIn() or .fadeOut(), it does not unhide elements or set display:none — the element stays in its current display state at the target opacity.
Yes. Unlike .fadeIn() and .fadeOut(), which default to 400 ms when duration is omitted, .fadeTo() requires duration to be explicitly specified. Pass milliseconds, "fast" (200 ms), or "slow" (600 ms). With duration set to 0, .fadeTo(0, opacity) is equivalent to .css("opacity", opacity).
No. .fadeTo() only changes opacity. It does not unhide hidden elements the way .fadeIn() does, and it does not set display:none when fading toward 0 the way .fadeOut() does. Use it when you want partial transparency — dimmed overlays, de-emphasized content, or hover states — while keeping the element in layout.
.fadeIn() unhides and fades to full opacity. .fadeOut() fades to transparent then hides. .animate({ opacity: n }) is the generic tween. .css("opacity", n) sets opacity instantly. .fadeTo() is the shorthand for animating to an exact opacity level without touching display.
With duration set to 0, .fadeTo() skips the animation and sets the opacity CSS property immediately — the same result as .css("opacity", opacity). Useful when you need the .fadeTo() API shape but want an instant change, or when effects are disabled via jQuery.fx.off.
The complete callback runs once per matched element when that element's fade finishes — not once for the entire set. Inside the callback, this refers to the DOM element being animated. Use .promise().done() when you need a single callback after all elements complete.
Did you know?
Unlike .fadeIn() and .fadeOut(), .fadeTo() is the only core fade method that requires an explicit duration. Pass 0 when you want an instant opacity change — .fadeTo(0, opacity) behaves exactly like .css("opacity", opacity), which is handy when you need the same API shape in both animated and instant code paths.