哪里有錯,為什么沒反應?
<!DOCTYPE html>
<html>
? ? <head>
? ? ? ? <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
? ? ? ? <title>jQuery動畫特效</title>
? ? </head>
? ?
? ? <body>
? ? ?<div id="div1">春季補水節(jié)</div>
? ? ? <input id="btntest1" type="button" value="左移"/> ?
? ? ? <input id="btntest2" type="button" ?value="右移"/>
? ? ? <div id="tip"></div>
? ? </body>
? ? <script type="text/javascript">
? ? $(function(){
? ? ? ? $("#div1").css({"position":"absolute"});
? ? ? ? $("#btntest1").bind("click",function(){
? ? ? ? ? ? $("#div1").animate({
? ? ? ? ? ? ? ? left:"-=50px"
? ? ? ? ? ? },3000,function(){
? ? ? ? ? ? ? ? $("#tip").html("左移完成");
? ? ? ? ? ? });
? ? ? ? });
? ? ? ??
? ? ? ? $("#btntest1").bind("click",function(){
? ? ? ? ? ? $("#div1").animate({
? ? ? ? ? ? ? ? left:"+=50px"
? ? ? ? ? ? },3000,function(){
? ? ? ? ? ? ? ? $("#tip").html("右移完成");
? ? ? ? ? ? });
? ? ? ? });
? ? ? ??
? ? ? ? });
? ??
? ? </script>
</html>
2016-03-02
兄弟你是不是沒有引入jQuery啊
2016-03-03
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script>
試試在head中加入這段,我加了之后能出效果了
2016-03-03
?<script>
??? $(function(){
??????? $("#div1").css({"position":"absolute"});
??????? $("#btntest1").bind("click",function(){
??????????? $("#div1").animate({
??????????????? left:"-=50px"
??????????? },3000,function(){
??????????????? $("#tip").html("左移完成");
??????????? ?
??????????? })
??????? });
?????? ?
??????? $("#btntest2").bind("click",function(){
??????????? $("#div1").animate({
??????????????? left:"+=50px"
??????????? },3000,function(){
??????????????? $("#tip").html("右移完成");
??????????? })
??????? });??
??????? });
??? </script>
有些地方有點小問題,但是我的代碼也是不能出效果,抱歉