猿问

为什么运行不了啊

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>jQuery动画特效</title>
        <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script>
        <style>
            #hezi{width:50px;height:50px;background:red;position:relative;left:100px;}
        </style>
    </head>
    
    <body>
        <div id="hezi"></div>
        <button id="toleft">左移</button>
        <button id="toright">右移</button>
        <script>
            $(function(){
                $("#toleft").bind("click",function(){
                    $("#hezi").animate({
                        left:"-=50px";
                    },1500);
                });
                $("#toright").bind("click",function(){
                    $("#hezi").animate({
                        left:"+=50px";
                    },1500);
                });
            });
        </script>
        
    </body>
</html>

牛奶老哥哥
浏览 1872回答 1
1回答

jerame

left:"-=50px";  left:"+=50px"; 这两行把分号去掉建议学会使用Firebug或其他浏览器的开发者工具,一看就看出来了……
随时随地看视频慕课网APP
我要回答