更新时间:2022-12-25 19:13:36
这是一种简单的方法:
var r = 0;
$('#icon').click(function(){
$(this).css('transform','rotate(' + (r += 360) + 'deg)');
});
这样,您的转换"属性将在每次点击时发生变化(直到有人点击1亿次左右).
I have an icon, which is rotated on click.
I'd like to "reset" it (without a page refresh), so it would rotate on every click.
$('#icon').click(function(){
$(this).css('transform','rotate(360deg)');
});
Here is the example: http://jsfiddle.net/tDvD9/1/
Thanks!
Here's one simple way:
var r = 0;
$('#icon').click(function(){
$(this).css('transform','rotate(' + (r += 360) + 'deg)');
});
That way your "transform" property will change on each click (until somebody clicks 100 million times or so).