2013-03-12 137 views
1

就像標題一樣,我想在圖像或div旋轉我的網頁。 而且,我發現在谷歌代碼中的jqueryrotate.js http://code.google.com/p/jqueryrotate/ 這位作者講述瞭如何使用jqueryrotate.js中的函數進行工作,並給出了jsfiddle中的一些示例,它看起來很棒! 但是,當它轉向我時,無論我怎麼嘗試拷貝作者的代碼,它都不起作用,圖像只是保持靜態。 我不知道它有什麼問題,並希望有人可以提供一些幫助。東西關於div和圖像旋轉360度由jquery

我的代碼編寫就像下面:

<html> 
<head> 
<scripttype="text/javascript"src="http://jqueryrotate.googlecode.com/svn/trunk/jQueryRotate.js"></script> 
<script type="text/javascript"> 
    var rotation = function(){ 
    $(document).ready(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> 
+0

我嘗試寫這樣的totura一些代碼,它只是不工作 – jabez128 2013-03-12 07:47:45

+0

你嘗試過什麼?除非你告訴我們你已經嘗試了什麼,否則我們不能說你做錯了什麼。 – Tetaxa 2013-03-12 07:48:28

+0

我發佈了我的代碼〜 – jabez128 2013-03-12 07:58:01

回答

3

您的腳本包括在HTML有一個錯字:

<scripttype="text/javascript"src="http://jqueryrotate.googlecode.com/svn/trunk/jQueryRotate.js"></script> 

應該

<script type="text/javascript" src="http://jqueryrotate.googlecode.com/svn/trunk/jQueryRotate.js"></script> 

,而不是包括包含腳本類型的腳本

3

您的代碼有一些錯誤。嘗試這個。

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; 
    } 
}); 
}; 

$(document).ready(function(){ 
rotation(); 

}); 

http://jsfiddle.net/TRQKE/

當然,你還需要糾正喬提到的腳本標籤。而你需要包含不包含您的代碼示例中的jQuery本身:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
+0

謝謝!它太好了 – jabez128 2013-03-12 08:09:47

+0

呃....仍然無法工作...我應該包括jqueryrotate.js嗎? – jabez128 2013-03-12 08:13:50

+0

像喬上面說過的,你的腳本鏈接也是錯誤的。 – Tetaxa 2013-03-12 08:15:47