How to fade an element in and out using jQuery

fadeIn

The jQuery fadeIn() method is used to fade in a hidden element.

Syntax

$(selector).fadeIn(speed, callback);
  1. speed is an optional parameter used to specify the duration of any applied effect. It can take on values such as “slow”, “fast”, or any other specified integer value of speed (in milliseconds).

  2. callback is another optional parameter that refers to a function that a user may want to execute at the end of fading.

fadeOut

The jQuery fadeOut() method is used to fade out a visible element.

Syntax

$(selector).fadeOut(speed, callback);
  1. speed is an optional parameter used to specify the duration of any applied effect. It can take on values such as “slow”, “fast”, or any other specified integer value of speed (in milliseconds).

  2. callback is another optional parameter that refers to a function a user may want to execute at the end of fading.

Example

Let’s visualize the workings of fadeIn() and fadeOut():

New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved