jQuery slideToggle()
with speed
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script>//from www . j a v a 2 s . c om <script> $(document).ready(function(){ $("button").click(function(){ $("p").slideToggle(1000); }); }); </script> </head> <body> <p>This is a paragraph.</p> <button>Toggle slideUp() and slideDown()</button> </body> </html>