2013-10-22 64 views
0

我想要獲得一個簡單的圖像旋轉點擊。這將適用於多圖像,因此我需要在jQuery中使用$(this)標記。我已經試過這一點,但沒有奏效:點擊旋轉'這個'圖像 - jQuery

$('.image').click(function(){ 
    $(this).rotate(180); 
}); 

DEMO http://jsfiddle.net/v6xtG/1/

我不希望添加CSS3類,因爲我需要IE8的支持

+0

看起來你可能一直在試圖使用[ jQuery旋轉](https://code.google.com/p/jqueryrotate/)插件。就我所知,這個功能在jQuery中默認不存在。如果您嘗試使用此插件,則需要在頁面上包含腳本。你真的試圖使用這個插件嗎? –

回答

0

使用transform:rotate(180deg)

$('.image').click(function(){ 
    $(this).css("transform","rotate(180deg)"); 
}); 

jsfiddle

+0

有沒有第二次點擊返回它的方法? – StevenPHP

+0

是不是一個[CSS3功能](http://www.cssrotate.com/)?該操作提到,他們不希望CSS3 –

+0

@StevenPHP http://jsfiddle.net/v6xtG/13/我想你想這個 –

0

Live Demo with multiple angles

申請的jQueryRotate.js或在你的代碼中使用此憑證參考:

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