jQuery slideToggle()
with callback function
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script>/*ww w . jav a 2 s . c om*/ <script> $(document).ready(function(){ $("button").click(function(){ $("p").slideToggle(1000, function(){ alert("The slideToggle() method is finished!"); }); }); }); </script> </head> <body> <p>This is a paragraph.</p> <button>Toggle slideUp() and slideDown()</button> </body> </html>