- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
jQuery slideToggle() Method
The slideToggle() method in jQuery is used to toggle between the slideUp() and slideDown() methods.
Syntax
The syntax is as follows −
$(selector).slideToggle(speed,easing,callback)
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 −
Example
<!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(){ $("p").slideToggle(); }); }); </script> </head> <body> <h2>Exam Info</h2> <p>Examination begins on 24th December. The students are requested to submit project report before 15th December.</p> <button>Toggle</button> </body> </html>
Output
This will produce the following output −
Click the “Toggle” button to hide info −
Click “Toggle” again to display the same info again −
- Related Articles
- jQuery eq() method
- jQuery toggle() Method
- jQuery is() Method
- jQuery $.proxy() Method
- jQuery after() method
- jQuery before() Method
- jQuery children() method
- jQuery next() method
- jQuery nextAll() method
- jQuery attr() Method
- jQuery fadeIn() Method
- jQuery fadeTo() Method
- jQuery fadeToggle() Method
- jQuery outerHeight() Method
- jQuery outerWidth() Method

Advertisements