fadeTo() animates a matched element to a target opacity. The opacity value ranges from 0 (transparent) to 1 (fully opaque).
$(selector).fadeTo(duration, opacity);
$("#b2").on("click", function () {
$("#d1").fadeTo("fast", 0.5);
});
$("#b2").on("click", function () {
$("#d1").fadeTo("fast", 1);
});
Demo: change and restore opacity with fadeTo() →
$("#d1").fadeTo("slow", 0.3);
The original collection also demonstrates fade durations on the fadeIn()/fadeOut() speed demo.
← Previous: fadeToggle() · jQuery Effects · Next: slideUp() / slideDown() →
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.