11.jQuery之自定义动画

注意:animate里面是一个对象,他有几个参数,详情可以参考官网

 1     <style>
 2         div {
 3             position: absolute;
 4             width: 200px;
 5             height: 200px;
 6             background-color: pink;
 7         }
 8     </style>
 9     <button>动起来</button>
10     <div></div>
11     <script>
12         $(function () {
13             $("button").click(function () {
14                 $("div").animate({
15                     left: 500,
16                     top: 300,
17                     opacity: .4,
18                     width: 500
19                 }, 500);
20             })
21         })
22     </script>