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);});

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.