不知道为什么不能左右移动
检查了多遍,还是不知道为什么
2015-11-10
<!DOCTYPE html> <html> <head> <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jQuery动画特效</title> <style> #box{height:140px;width:140px;background-color:orange;position:absolute;left:200px;} #leftBtn{position:absolute;top:150px;} #rightBtn{position:absolute;top:150px;left:80px;} </style> </head> <body> <div id="box"></div> <input id="leftBtn" type="button" value="左移"> <input id="rightBtn" type="button" value="右移"> <script type="text/javascript"> $(function(){ var box = $("#box"); $("#leftBtn").bind("click",function(){ box.animate({ left: "-=50px" },1000) }); $("#rightBtn").bind("click",function(){ box.animate({ left: "+=50px" },1000) }); }); </script> </body> </html>
试试看
举报