.fadeTo() (since jQuery 1.0) animates matched elements to a specific opacity between 0 and 1. It is like .fadeIn(), but that method always unhides and goes to full opacity. Returns the jQuery object for chaining.
Pass a duration and a target opacity (0–1). Optionally add easing and a complete callback.
Select the target ($("#book")).
If it may be hidden and you need it visible, call .show() first.
Call .fadeTo(duration, opacity) — both arguments are required for a normal fade.
Optionally pass easing (since 1.4.3) and a complete callback.
For spam clicks, chain .stop(true, true) before .fadeTo().
Piece
Required?
Role
duration
Yes
Milliseconds, "fast" (200), or "slow" (600)
opacity
Yes
Number from 0 (transparent) to 1 (opaque)
easing
No
Default "swing"; also "linear" (since 1.4.3)
complete
No
Runs once per matched element when its fade ends
Return value
—
jQuery object (chainable)
Pseudocode
Pseudocode
call $(elements).fadeTo(duration, opacity, easing?, complete?)
for each matched element:
animate opacity → target (0…1) over duration
do NOT change display
if complete was provided:
call complete once for this element
(this = the DOM element)
return the jQuery set for chaining
// Special case:
// fadeTo(0, opacity) ≡ css("opacity", opacity)
Open → backdrop shown, then dims to 0.4
Close → opacity → 0, then hide() in callback
How It Works
show. Makes the backdrop participate in layout/stacking.
fadeTo. Soft dim to 40% — not a full hide.
Close. Animate opacity to 0, then .hide() in the callback.
Why fadeTo. You control the exact dim level for overlays.
Watch outs
Edge Cases & Pitfalls
Case
What happens
Fix
Omit duration
Invalid / unexpected call
Always pass duration (ms, fast, or slow)
Element is display: none
Opacity may change but stay invisible
Call .show() first when you need it visible
Expect hide at opacity 0
Element stays in layout
Use .fadeOut() or .hide() after
Spam clicks
Queued fades stack up
.stop(true, true) before .fadeTo()
jQuery.fx.off
Duration becomes 0
Respect reduced-motion / accessibility settings
Compatibility
Browser Support
.fadeTo() has been part of jQuery since 1.0 (easing argument since 1.4.3). It works in every browser that runs your loaded jQuery version.
✓ Stable · jQuery 1.0+
jQuery .fadeTo()
Supported across jQuery 1.x, 2.x, and 3.x. Prefer a current jQuery 3.x build. Always pass duration and an opacity between 0 and 1.
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
.fadeTo()Universal
Bottom line: Safe for dimming and partial opacity. Remember: duration is required, and display is never changed automatically.
Analysis
Performance Notes
Approach
Cost
Best for
One element fadeTo
Cheap
Dim cards, overlays, hover states
Many elements at once
More paint work
Prefer one wrapper over many children
Queued spam clicks
Wasted frames
Always .stop(true, true) on busy controls
Opacity tweens are inexpensive for a few elements. Cost climbs with large sets or stacked queues — stop before fade, and dim one backdrop instead of dozens of children.
Remember
Key Takeaways
Role: animate to an exact opacity — since jQuery 1.0.
Call:$el.fadeTo(duration, opacity) — duration is required.
vs fadeIn/Out: no unhide · no display: none.
Instant:.fadeTo(0, n) equals .css("opacity", n).
One line:.fadeTo() animates opacity to an exact level without changing display — ideal for dimming.
Frequently Asked Questions
.fadeTo() animates the opacity of matched elements to a specific value between 0 and 1. Unlike .fadeIn() or .fadeOut(), it does not unhide elements or set display:none — the element keeps its current display and ends at the target opacity.
Yes. Unlike .fadeIn() and .fadeOut(), which default to 400 ms when duration is omitted, .fadeTo() requires duration to be specified. Pass milliseconds, "fast" (200), or "slow" (600). With duration 0, .fadeTo(0, opacity) equals .css("opacity", opacity).
No. It only changes opacity. It does not unhide like .fadeIn(), and it does not set display:none when fading toward 0 like .fadeOut(). Use it for partial transparency while keeping the element in layout.
.fadeIn() unhides and fades to full opacity. .fadeOut() fades to transparent then hides. .css("opacity", n) sets opacity instantly. .fadeTo() animates to an exact opacity without touching display.
With duration 0, .fadeTo() skips animation and sets opacity immediately — the same result as .css("opacity", opacity). Useful for an instant change while keeping the .fadeTo() call shape.
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.