<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script type="text/javascript" src="../js/jquery-1.9.0.min.js" ></script> <script> $(document).ready(function(){ $("button").click(function(){ $("div").animate({ height:‘toggle‘, opacity:‘toggle‘ }); }); }) </script> <title></title> </head> <body> <button class="button1">开始动画</button> <div style="background:#98bf21;height:100px;width:100px;position:absolute;"> </body> </html>
将width与opacity属性同时设置成为toggle,会在宽度变化的同时变化透明度