jQuery Fade
<!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> </head> <body> <button id="showBtn">Show</button> <button id="hideBtn">Hide</button> <div id="box" style="display:none; width:100px; height:100px; background-color:tomato;"></div> <script> $("#showBtn").click(function() { $("#box").fadeIn("slow"); }); $("#hideBtn").click(function() { $("#box").fadeOut(1000); }); </script> </body> </html>