jQuery fadeIn() and fadeOut()

fadeIn() reveals a hidden element by increasing its opacity, while fadeOut() hides a visible element by reducing opacity.

fadeIn() and fadeOut() Top ↑

$("#d1").fadeOut();
$("#d1").fadeIn();

Fade on Button Clicks Top ↑

$("#b2").on("click", function () {
    $("#d1").fadeOut();
});

$("#b1").on("click", function () {
    $("#d1").fadeIn();
});

Demo: fade in and fade out →

Set the Fade Duration Top ↑

$("#d1").fadeIn("fast");
$("#d1").fadeOut(800);

Demo: fade with slow, fast and millisecond durations →

Run Code After the Fade Completes Top ↑

A completion callback runs after the animation finishes. This is preferable to guessing the end time with a separate timer.

$("#d1").fadeOut(400, function () {
    alert("Fade-out complete");
});

Demo: fade effect followed by an alert →

← Previous: toggle() · jQuery Effects · Next: fadeToggle() →






plus2net.com






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer