1 <!DOCTYPE html> 2 <html> 3 <head> 4 <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"> 5 </script> 6 <script> 7 $(document).ready(function(){ 8 $("button").click(function(){ 9 $("div").animate({ 10 left:‘250px‘, 11 opacity:‘0.5‘, 12 height:‘150px‘, 13 width:‘150px‘ 14 },2000,function(){ 15 alert("动画完成了")}); 16 }); 17 }); 18 </script> 19 </head> 20 21 <body> 22 <button>Start Animation</button> 23 <p>By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!</p> 24 <div style="background:#98bf21;height:100px;width:100px;position:absolute;"> 25 </div> 26 27 </body> 28 </html>
之前自己写的一直不成功,是因为直接写了alert("动画加载已经完成"),而忘记了这里应该是一个函数。
时间: 2024-10-29 14:20:01