jQuery Effect fadeOut() Method

jQueryWeb DevelopmentFront End Technology

The fadeout() method in jQuery is used to give a fading effect by changing the opacity for the selected elements. The fading effect changes from visible to hidden.

Syntax

The syntax is as follows −

$(selector).fadeOut(speed,easing,callback)

Above, the parameter speed is the speed of the fading effect. Here, easing is the speed of the element in different points of the animation, whereas callback is a function to be executed after fadeOut() completes.

Example

Let us now see an example to implement the jQuery fadeout() method 

 Live Demo

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
   $(document).ready(function(){
      $("button").click(function(){
         $("h2").fadeOut();
      });
   });
</script>
</head>
<body>
<h2>Demo Heading</h2>
<button>Click to Fade out</button>
</body>
</html>

Output

This will produce the following output −

Click the button to fade out heading. Now, you can’t see the heading since it faded out i.e. from visible to hidden −

raja
Published on 31-Dec-2019 11:54:15
Advertisements