jQuery – Fade an element

With jQuery, we can easily fade any HTML element. Fade means making an element to hide or show in and out. In this lesson, we will learn how to easily fade in and out any element with jQuery. Let us see the methods available to fulfill our purpose of fading in and out HTML elements:

  • fadeIn(): Fade in an element
  • fadeOut(): Fade out an element
  • fadeToggle(): Fade toggle an element

jQuery fade in

To fade in an invisible element, use the jQuery fadeIn() method. In the below example, we will fade the <div> element. Let us see an example:

Output

jQuery Fade in

jQuery fade out

To fade out a visible element, use the jQuery fadeOut() method. In the below example, we will fade out the <div> element. Let us see an example:

Output

jQuery Fade Out

jQuery fade toggle

Set both the fade and fade out if you want to set a toggle button. The jQuery fadeToggle() method fulfills this purpose. You can easily toggle between the fadeIn() and fadeOut() methods using the fadeToggle().

Fade in the elements if they fade out using the fadeIn() method in jQuery. Fade out the elements if they are fade in using the fadeOut() method in jQuery.

Let us see an example wherein we will toggle on the click of a single button:

Output

jQuery Fade Toggle

jQuery - Toggle an element
jQuery - Slide an Element
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading