jQuery fadeOut()
with speed and function
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script>//from w w w . j a v a 2 s. com <script> $(document).ready(function(){ $(".btn1").click(function(){ $("p").fadeOut(1000, function(){ document.getElementById("demo").innerHTML = "fadeOut() method is finished!"; }); }); $(".btn2").click(function(){ $("p").fadeIn(1000, function(){ document.getElementById("demo").innerHTML = "fadeIn() method is finished!"; }); }); }); </script> </head> <body> <p id="demo"></p> <p>This is a paragraph.</p> <button class="btn1">Fade out</button> <button class="btn2">Fade in</button> </body> </html>