Try It Editor
Tip: Press
Ctrl/⌘ + Enter
to Run
▶ Run
Reset
Copy
Download
Code
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>CSS class + jQuery effects</title> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <style> #box{width:160px;height:80px;background:#e1bee7;transition:transform .25s} #box.active{transform:scale(1.1)} </style> </head> <body> <button id="go">Toggle CSS + fade</button> <div id="box"></div> <script> $("#go").on("click", function(){ $("#box").toggleClass("active").fadeToggle(200); }); </script> </body> </html>
Output