2011-12-20 19 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