2011-12-20 65 views
0

我对jquery很新,我很想知道为什么我的函数不工作。我正在做一个'圣诞老人'动画。他的身体和一只手臂彼此分开。这部动画的目的是单手挥动一次。这里是我的代码:jquery中的动画

HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title>Naamloos document</title> 
</head> 

<body> 

<div id="redbtn"></div> 

<div id="santa_body"> 
    <div id="santa_arm"><img src="onderdelen/hand.png" /></div> 
    <div id="santa_corpse"><img src="onderdelen/kerstman.png" /></div> 
</div> 

</body> 
</html> 

CSS

#redbtn{ 
    width:50px; 
    height:50px; 
    background-color:#F00; 
    float:left; 
    margin-top:30px; 
} 

#santa_body{ 
height:100px; 
width:100px; 
margin-left:auto; 
margin-right:auto; 
z-index:3; 



} 

#santa_arm{ 
margin-top: 100px; 
margin-right: auto; 
margin-bottom: 0; 
margin-left: 330px; 
background-repeat: no-repeat; 
background-position: left top; 
width: 400px; 
height:200px; 
z-index:1; 
float:left; 
} 

#santa_corpse{ 
z-index: 2; 
width:500px; 
height:600px; 
position:absolute; 
background-repeat:no-repeat; 
float:right; 
} 

的JavaScript

$("#redbtn").click(
    function(){ 
       $("#santa_arm").animate({ 
       path : new $.path.arc({ 
         center : [200,200], 
         radius : 150, 
         start : 0, 
         end  : -360 * 40, 
         dir : -1 
        }) 
      },40000); 
    }); 
+2

首先 - 我没有看到jQuery JS文件链接到您的HTML页面... – ManseUK 2011-12-20 11:45:45

+0

任何即时通讯猜测您使用此 - > http://motyar.blogspot.com /2010/08/jquery-animate-in-circular-path.html再次未链接? – ManseUK 2011-12-20 11:46:36

+0

运行时会出现什么错误?调试器中的任何东西? JavaScript控制台?什么? (抱歉的多个评论) – ManseUK 2011-12-20 11:47:17

回答

0

没有得到你的阙但仍然尝试使用firefox中的萤火虫检查您的网页,如上面的评论所述,找出问题并提及出现的实际错误讯息(如果有的话)。 PS:在$(document).ready()中移动“$(”#redbtn“)。click()”函数后尝试。块。 (只是说,因为你是新的:P)

+0

谢谢:) Firebug没有注意到任何错误... – kim 2011-12-20 12:10:34

+0

我说太快了,当我点击红色按钮(#redbtn)萤火虫给我的错误:$ .path是undefined [Afbreken op deze fout ]路径:new $ .path.arc({ – kim 2011-12-20 12:12:41

+0

激活萤火虫,重新加载您的页面,并通过“网络”选项卡确认,如果您缺少链接任何.js文件(404找不到)。 – MrClan 2011-12-20 12:27:39