.fadeIn() / .fadeOut() / .fadeToggle()
method
Animate opacity changes to show or hide elements smoothly.
Syntax
$(selector).fadeIn(duration) .fadeOut(duration)
Example
javascript
$('#notification').fadeIn(400);
$('#notification').fadeOut(400);
$('#overlay').fadeToggle(300);
// Chain: fade out then remove
$('#alert').fadeOut(500, function() {
$(this).remove();
});
// fadeTo — fade to specific opacity
$('#img').fadeTo(300, 0.5); // 50% opacity