【发布时间】:2011-12-20 20:02:20
【问题描述】:
我对 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);
});
【问题讨论】:
-
首先 - 我没有看到您的 HTML 页面上链接的 jQuery JS 文件 ...
-
任何我猜你使用这个 -> motyar.blogspot.com/2010/08/… 再次没有链接?
-
运行时会出现什么错误?调试器中有什么? javascript控制台?任何事物 ? (对不起,多个 cmets)
-
所以我必须将 Jquery 代码放在外部 .js 文件中吗?是的,我正在尝试您那里的代码。我没有收到任何错误...
-
不,您不需要将代码放在外部 js 文件中......要使用 jquery,您必须在页面中包含 jQuery 库 js 文件......并使用插件(我链接的页面到上面)你还必须链接到一个额外的库文件......见这里 -> docs.jquery.com/Downloading_jQuery