<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> body{font-size:12px;} div{width:100px;height:100px;background:red;position:absolute;} </style> <script type="text/javascript" src="js/jquery-3.3.1.js"></script> </head> <body> <button id="bt1">开始动画</button> <div>我也会动</div> <script type="text/javascript"> $(document).ready(function(){ $('#bt1').click(function(){ $('.div1').animate({height:'500px'},'slow') $('.div1').animate({width:'500px'},'slow') $('.div1').animate({fontSize:'100px',fontWeight:'bold'}) $('.div1').animate({height:'100px'},'fast') $('.div1').animate({width:'100px'},'fast') $('.div1').animate({fontSize:'12px',fontWeight:'normal'}) }) }) </script> </body> </html>
方法类似于CSS,但是更加简单化。
通过事件触发动画,动画通过队列一个个展示,变成最后的效果