為什么運行不了
<!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>
? ? div{
? ? ? ? background:orange;
? ? ? ? width:100px;
? ? ? ? height:100px;
? ? ? ? position:absolute;
? ? ? ? left:200px;
? ? ? ? top:200px;
? ? ? ? }
? ? </style>
? ? </head>
? ?
? ? <body>
? ?
? ? <input type="button" value="向左移" id="left" />
? ? <input type="button" value="向右移" id="right" />
? ? <div></div>
<script type="text/javascript">
$(function (){
? ? $("#left").bind("click",function(){?
? ? ? ? ?$("div").animate({left:'-=50px';},800)
? ? ? ? ?
? ? ? ? ?})
? ? ? ? ?
? ? $("#right").bind("click",function (){
? ? ? ? $("div").animate({left:'+=50px'},800)
? ? ? ??
? ? ? ??
? ? })
? ??
? ??
})
</script>
? ? </body>
</html>
2016-04-11
?$("#left").bind("click",function(){?
? ? ? ? ?$("div").animate({left:'-=50px';},800)
? })
把left:'-=50px'; 這里面的分號去掉就可以了
2016-04-13
<!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>
??????????? div{
??????????????? position:relative;
??????????????? margin:5px;
??????????????? width:100px;
??????????????? height:100px;
??????????????? border:2px solid #999;
??????????????? background:#f60;
?????????????? ?
??????????????? }
??????? </style>
??? </head>
??? <body>
??????? <button class="i">按鈕1--左移動</button>
??????? <button class="j">按鈕2--右移動</button>
??????? <div>hello world</div>
??????? <script type="text/javascript">
??????????? $(function)(){
??????????????? $(".i").bind("click",function(){
??????????????????? $("div").animate({
??????????????????????? left:"+=50px" },1000,function(){
??????????????????? $(".j").bind("click",function(){
??????????????????????? $("div").animate({
??????????????????????? right:"-=50" },1000,function()
??????????????????????? {$("div").html(執(zhí)行結束!)})
??????????????????? })})})}
????????????????????? ?
??????? </script>
??? </body>
</html>
我這個哪里有問題。