jQuery fadeToggle()
with callback
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script>//from w w w . ja va2 s .c o m <script> $(document).ready(function(){ $("button").click(function(){ $("p").fadeToggle("slow", function(){ document.getElementById("demo").innerHTML = "The fadeToggle effect is finished!"; }); }); }); </script> </head> <body> <p id="demo"></p> <button>Click me</button> <p>This is a paragraph.</p> </body> </html>