Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

javascript

How to fade an element in and out using jQuery

Sarvech Qadir

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():

RELATED TAGS

javascript

CONTRIBUTOR

Sarvech Qadir
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring