【问题标题】:animation in jqueryjquery中的动画
【发布时间】: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

标签: jquery html css animation


【解决方案1】:

没有正确回答您的问题,但仍尝试使用 firefox 中的 firebug 检查您的页面,正如上面的 cmets 所说,以确定问题,并提及出现的实际错误消息(如果有)。 PS:在 $(document).ready(); 中移动你的 "$("#redbtn").click()" 函数后尝试堵塞。 (只是说,因为你是新人,:P)

【讨论】:

  • 我说得太早了,当我点击红色按钮 (#redbtn) 时,萤火虫给了我错误:$.path is undefined [Afbreken op deze fout] path : new $.path.arc ({
  • 激活萤火虫,重新加载您的页面,如果您缺少链接任何 .js 文件(未找到 404),请通过“网络”选项卡确认。
  • 关于我导入的每个 .js 文件,上面写着:status: 304 Not Modified。
  • 如果是这样,那么您链接的所有文件都已正确加载,这意味着,您肯定错过了一些外部文件,将名为“path”的函数添加到基础 jQuery 对象的文件。您能否提供指向您从中获取此代码的参考网址的链接?还有你正在处理的 html 文件的当前副本(所有 js 和 css 文件都正确链接)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-04-21
  • 2010-11-28
  • 2015-01-21
  • 1970-01-01
  • 1970-01-01
  • 2010-09-16
  • 2010-10-19
相关资源
最近更新 更多