jQuery slideToggle() Method

The slideToggle() method in jQuery is used to toggle between the slideUp() and slideDown() methods.


The syntax is as follows −


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

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


 Live Demo

<!DOCTYPE html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<h2>Exam Info</h2>
<p>Examination begins on 24th December. The students are requested to submit project report before 15th December.</p>


This will produce the following output −

Click the “Toggle” button to hide info −

Click “Toggle” again to display the same info again −