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]
How to Connect MySQL Database in Python?
In this article, I will share with you h...How to Remove Duplicate Values from a JavaScript Array
Use the indexOf() Method Yo...How to Set the Value of Input Text Box using jQuery
Use the jQuery val() Method You can s...How To Set Header In maatwebsite/excel Export In Laravel
Today, we are share with you how to set...Laravel 8 - Paypal Payment Gateway Integration
Laravel 8 PayPal Integration is the impo...