2016-02-14 138 views
0

我試圖創建圖像旋轉,但它不工作。我嘗試了不同網站的不同代碼,但不知道什麼是錯的。jQuery - 旋轉圖像

這是我的代碼。

var value = 0 
 
$("#image").rotate({ 
 
    bind: 
 
    { 
 
    click: function(){ 
 
     value +=90; 
 
     $(this).rotate({ animateTo:value}) 
 
    } 
 
    } 
 
});
#image{ 
 
    margin:200px 200px; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script type="text/javascript" src="http://cdn.sobekrepository.org/includes/jquery-rotate/2.2/jquery-rotate.min.js"></script> 
 
<script type="text/javascript" src="http://beneposto.pl/jqueryrotate/js/jQueryRotateCompressed.js"></script> 
 
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script> 
 
<img src="http://jqueryrotate.com/images/chrome_32x32.png" id="image" onclick="" />

回答

0

在你的榜樣,jQuery沒有定義,請檢查下面的代碼:

var value = 0 
 
$("#image").rotate({ 
 
    bind: { 
 
    click: function() { 
 
     value += 90; 
 
     $(this).rotate({ 
 
     animateTo: value 
 
     }) 
 
    } 
 
    } 
 
});
#image { 
 
    margin: 200px 200px; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script type="text/javascript" src="include/jQueryRotate.js"></script> 
 
<script type="text/javascript" src="http://beneposto.pl/jqueryrotate/js/jQueryRotateCompressed.js"></script> 
 
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script> 
 
<img src="http://i.forbesimg.com/media/lists/companies/apple_416x416.jpg" id="image" onclick="" />

+0

你的代碼段的網站,但它不能在正常工作在我的代碼工作.. –

+0

檢查您的代碼! –