连续旋转图像
我想在我的网站上放置旋转徽标。我的意思是它应该不断旋转。我尝试过用 jquery 这样做。 请看一下并建议我哪里出错了。为什么这段代码不起作用。请帮助我,
var rotation = function (){
$("#img").rotate({
angle:0,
animateTo:360,
callback: rotation,
easing: function (x,t,b,c,d){ // t: current time, b: begInnIng value, c: change In value, d: duration
return c*(t/d)+b;
}
});
}
rotation();
我在我的 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" />
<script type="text/javascript" src="jquery-1.4.4.js"></script>
<script type="text/javascript" src="jquery.easing.1.3.js"></script>
<script type="text/javascript">
var rotation = function (){
$("#img").rotate({
angle:0,
animateTo:360,
callback: rotation,
easing: function (x,t,b,c,d){ // t: current time, b: begInnIng value, c: change In value, d: duration
return c*(t/d)+b;
}
});
}
rotation();
</script>
<title>Untitled Document</title>
</head>
<body>
<img src="LMIH_LOGO.png" width="174" height="322" name="img" id="img" />
</body>
</html>
它不起作用。请任何人帮助我
I want to put rotating logo in my website. I mean it should be continuously rotating. I have tried doing like this with jquery.
please have a look and suggest me where i am going wrong. Why this code is not working. Please help me
var rotation = function (){
$("#img").rotate({
angle:0,
animateTo:360,
callback: rotation,
easing: function (x,t,b,c,d){ // t: current time, b: begInnIng value, c: change In value, d: duration
return c*(t/d)+b;
}
});
}
rotation();
I have used this code in my html like this
<!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" />
<script type="text/javascript" src="jquery-1.4.4.js"></script>
<script type="text/javascript" src="jquery.easing.1.3.js"></script>
<script type="text/javascript">
var rotation = function (){
$("#img").rotate({
angle:0,
animateTo:360,
callback: rotation,
easing: function (x,t,b,c,d){ // t: current time, b: begInnIng value, c: change In value, d: duration
return c*(t/d)+b;
}
});
}
rotation();
</script>
<title>Untitled Document</title>
</head>
<body>
<img src="LMIH_LOGO.png" width="174" height="322" name="img" id="img" />
</body>
</html>
Its not working. Please anybody help me in this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
jQuery 没有 .rotate() 函数。我认为您的意思是包含 jQuery Rotate 插件。
jQuery does not have a .rotate() function. I think you mean to be including the jQuery Rotate plugin.
我不确定代码本身是否存在错误,或者它是否只是没有启动,但我要尝试的第一件事是将函数调用移动到文档就绪侦听器...
尝试:
而不是仅仅
问题可能是当该函数执行时,您尝试操作的图像实际上并未加载到 dom 中。将其移至文档就绪回调将确保 dom 在执行前完全加载。
I'm not sure if there is a bug within the code it self or if its just not starting, but my first thing to try would be to move the function call to rotate to the document ready listener...
Try:
instead of just
The problem may be that the image you are trying to manipulate isnt actually loaded in the dom when this function executes. Moving it to the document ready callback will ensure the dom is fully loaded before executing.