jQuery animate()
opacity
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script>/*w ww .j a va2 s. c o m*/ <script> $(document).ready(function(){ $("#btn1").click(function(){ $("#box").animate({opacity: "0.2"}); }); $("#btn2").click(function(){ $("#box").animate({opacity: "1"}); }); }); </script> </head> <body> <button id="btn1">Animate opacity</button> <button id="btn2">Reset opacity</button> <div id="box" style="background:red;height:100px;width:100px;margin:6px;"></div> </body> </html>