<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#btnFadeIn").click(function(){ $("#divFadeIn1").fadeIn(); $("#divFadeIn2").fadeIn("slow"); $("#divFadeIn3").fadeIn(3000); }); $("#btnFadeOut").click(function(){ $("#divFadeIn1").fadeOut(); $("#divFadeIn2").fadeOut("slow"); $("#divFadeIn3").fadeOut(3000); }); $("#btnFadeToggle").click(function(){ $("#divFadeIn1").fadeToggle(); $("#divFadeIn2").fadeToggle("slow"); $("#divFadeIn3").fadeToggle(3000); }); $("#btnFadeTo").click(function(){ $("#divFadeIn1").fadeTo("slow", 0.15); $("#divFadeIn2").fadeTo("slow", 0.4); $("#divFadeIn3").fadeTo("slow", 0.7); }); }); </script> </head> <body> <div id="divFadeIn"> <p>Demonstrate fadeIn with different parameters.</p> <button id="btnFadeIn">Click to fade in boxes</button> <button id="btnFadeOut">Click to fade out boxes</button> <button id="btnFadeToggle">Click to fade toggle boxes</button> <button id="btnFadeTo">Click to fade to boxes</button> <br><br> <div id="divFadeIn1" style="width:80px;height:80px;display:none;background-color:red;"></div><br> <div id="divFadeIn2" style="width:80px;height:80px;display:none;background-color:green;"></div><br> <div id="divFadeIn3" style="width:80px;height:80px;display:none;background-color:blue;"></div> </div> </body> </html>
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more