.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.
Syntax
Start with these common calls. Keep them short and readable.
Learn jQuery .fadeTo(): animate matched elements to a specific opacity between 0 and 1 since 1.0, required duration, easing since 1.4.3, no display change, and compare with fadeIn, fadeOut, fadeToggle, and .css().
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Select the target ($("#book")).
Step 2
If it may be hidden and you need it visible, call .show() first.
Step 3
Call .fadeTo(duration, opacity) — both arguments are required for a normal fade.
Return Value
Return Value
Description
jQuery object
Most setters and traversing helpers return the jQuery collection so you can chain more methods.
jQuery Examples
Example 1 — Dim to 50% Opacity
From the jQuery docs: fade a visible element to 0.5 with a complete callback.
jQuery
$("#clickme").on("click", function () {
$("#book").fadeTo("slow", 0.5, function () {
// Animation complete.
});
});
Click a square → fadeTo("fast", random 0…1)
Each click picks a new opacity target
How It Works
fast. Duration is 200 ms.
Math.random(). Target opacity is between 0 and 1.
Per click. Only the clicked div animates.
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.