Open In App

jQuery | slideToggle() Method

The slideToggle() Method in jQuery is used to show the hidden elements or hide the visible elements respectively i.e. it toggles between the slideUp() and slideDown() methods.

Syntax:



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

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

Below example illustrates the slideToggle() method in jQuery:



Example: This example display or hide the element.




<!DOCTYPE html>
<html>
  
<head>
    <title>
        jQuery slideToggle() Method
    </title>
      
    <script src=
    </script>
      
    <!-- Script to illustrates slideToggle() method -->
    <script>
        $(document).ready(function() {
            $("button").click(function() {
                $("h1").slideToggle();
            });
        });
    </script>
</head>
  
<body>
  
    <h1 style="color:green">
        GeeksforGeeks
    </h1>
  
    <button>
        Click on button to hide/show content
    </button>
</body>
  
</html>                    

Output:


Article Tags :