我试图让图像在每次点击时旋转到位(图像是一个老式的电视旋钮)。尽管我尽了最大努力,但我无法让它工作。
代码如下:
var value = 0
$("#img").rotate({
bind:
{
click: function(){
value +=90;
$(this).rotate({ animateTo:value})
}
}
});
有一个 jQuery 补丁,可以让您执行以下操作: http ://www.zachstronaut.com/posts/2009/08/07/jquery-animate-css-rotate-scale.html
$('#img').click(function(){
$(this).animate({rotate: '+=10deg'}, 0);
});
或者这个插件: http ://code.google.com/p/jqueryrotate/它允许这样的东西:
$("#img").rotate({
bind: {
click: function() {
$(this).rotate({
animateTo: (parseInt($(this).getRotateAngle()) + 10),
easing: $.easing.easeInOutExpo
})
}
}
});