我在写网页的时候想让其中一张图片实现360度旋转,用js不用css3
在谷歌上找到了一个叫jqueryrotate.js的文件
地址:http://code.google.com/p/jqueryrotate/wiki/Examples
作者说可以用其中包含的函数实现图片旋转功能,并做了演示
但是当我按照作者示范在写了代码,甚至是原本搬运代码,都没有实现图片旋转的功能
<html>
<head>
<script type="text/javascript" src="http://jqueryrotate.googlecode.com/svn/trunk/jQueryRotate.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>
</head>
<body>
<img style="margin:10px;"src="/arrow.png" id="img">
</body>
</html>
我以为是浏览器的问题,换了chrome,ie,firefox均不行
纠结了好几个小时,实在没找出问题在哪
请善良的同志们给点意见!
要是能顺便附上一段成功运行的代码范例的话那就最好了!

解决方案 »

  1.   

    BTY:把script包含在$(document).ready(function(){})里面也不对
      

  2.   

    把JS调用代码放到<img后面去,或者写到document.ready里!
      

  3.   

    <html>
    <head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://jqueryrotate.googlecode.com/svn/trunk/jQueryRotate.js"></script></head>
    <body>
    <img style="margin:10px;"src="http://www.baidu.com/img/shouye_b5486898c692066bd2cbaeda86d74448.gif" id="img">
    <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>
    </body>
    </html>
      

  4.   

    我想你有两个问题,第一个是没有引入jQuery库,另一个是,你确定旋转360°你能和原图区别出来?