O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Fading Elements Out

$("img").fadeOut(1000, "swing", function() {   $(this).fadeIn(1000);});

The .fadeIn( [duration] [, easing] [, callback]) method provides the optional duration, easing, and callback options, allowing you to animate fading the opacity of an element from its current value to 0.

For example, the following code applies an animation of 1 second with swing easing to all image elements. Then, when completed, it fades them back in again:

$("img").fadeOut(1000, "swing", function() { $(this).fadeIn(1000);});

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required