jQuery provides easy ways to animate any element. One of the effect is fading effect. Fade effect workds as gradual increase and decrease in the opacity in the selected element. jQuery provides four method to create fade effects.
In this article, we will describe all methods one by one. So let's start from fadeIn() method.
jQuery fadeIn() method used to show hidden element in fade effect.
$(selector).fadeIn(duration, callback);
duration is string 'slow', 'fast' or milliseconds
callback is a optional function which executes after the fadeIn effect completes.
$('.normal').fadeIn();
$('#slow').fadeIn('slow');
$('div').fadeIn(1000, function() {
alert('fadeIn effect completed.');
});
jQuery fadeOut() method
jQuery fadeOut() method used to hide element in fade effect.
$(selector).fadeOut(duration, callback);
duration is string 'slow', 'fast' or milliseconds
callback is a optional function which executes after the fadeOut effect completes.
$('.normal').fadeOut();
$('div').fadeOut(1000);
$('#slow').fadeOut('slow', function() {
alert('fadeOut effect completed.');
});
jQuery fadeToggle() method
jQuery fadeToggle() method used to toggle elements fadeIn() method and fadeOut() method. It shows hidden elements and hide elements in fade effect.
$(selector).fadeToggle(duration, callback);
duration is string 'slow', 'fast' or milliseconds
callback is a optional function which executes after the fadeToggle effect completes.
$('.normal').fadeToggle();
$('div').fadeToggle(1000);
$('#slow').fadeToggle('slow', function() {
alert('fadeToggle effect completed.');
});
jQuery fadeTo() method
jQuery fadeTo() method used to set opacity of element in given value.
$(selector).fadeTo(duration, opacity, callback);
duration is string 'slow', 'fast' or milliseconds
opacity decimal between 0 and 1 where 0 will hide element and 1 will do nothing.
callback is a optional function which executes after the fadeTo effect completes.
$('.normal').fadeTo();
$('div').fadeTo(1000);
$('#slow').fadeTo('slow', function() {
alert('fadeTo effect completed.');
});
I hope it will help you.
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
Laravel Eloquent Has Many Through Relationship Tutorial with Example
Laravel provides eloquent relationship w...How to Install FileZilla FTP client in Ubuntu
FileZilla is a open-source multi-platfor...Laravel Eloquent One to One Polymorphic Relationship Tutorial with Example
While designing database structure, you...9 basic commands that every new Linux users need to know
Whenever thinking about Linux, most of p...How to Run Angular project on different port other than 4200
Sometimes you need to run two different...