Open In App

jQuery fadeIn() Method

The fadeIn() method in jQuery is used to change the opacity of selected elements from hidden to visible. The hidden elements will not be display. 

Syntax:



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

Parameters: This method accepts three parameters as mentioned above and described below:

Example 1: This example describes fadeIn() method with speed 1000 milliseconds. 






<!DOCTYPE html>
<html>
  
<head>
    <script src=
    </script>
    
    <title>
        fadeIn() Method in jQuery
    </title>
  
    <style>
        #Outer {
            border: 1px solid black;
            padding-top: 40px;
            height: 140px;
            background: green;
            display: none;
        }
    </style>
</head>
  
<body style="text-align:center;">
  
    <div id="Outer">
        <h1 style="color:white;">
            GeeksForGeeks
        </h1>
    </div><br>
  
    <button id="btn">
        Fade In
    </button>
  
    <!-- jQuery script of fadeIn() method -->
    <script>
        $(document).ready(function () {
            $("#btn").click(function () {
                $("#Outer").fadeIn(1000);
            });
        });
    </script>
</body>
  
</html>

Output: 

 

Example 2: This example describes fadeIn() method with easing “swing”. 




<!DOCTYPE html>
<html>
  
<head>
    <script src=
    </script>
    
    <title>
        fadeIn() Method in jQuery
    </title>
  
    <style>
        #Outer {
            border: 1px solid black;
            padding-top: 40px;
            height: 140px;
            background: green;
            display: none;
        }
    </style>
</head>
  
<body style="text-align:center;">
  
    <div id="Outer">
        <h1 style="color:white;">
            GeeksForGeeks
        </h1>
    </div><br>
  
    <button id="btn">
        Fade In
    </button>
  
    <!-- jQuery script of fadeIn() method -->
    <script>
        $(document).ready(function () {
            $("#btn").click(function () {
                $("#Outer").fadeIn("swing");
            });
        });
    </script>
</body>
  
</html>

Output: 

 


Article Tags :