我有以下的jQuery的扩展:jQuery旋转函数不会触发。
(function ($) { //jQuery plugin extension
jQuery.fn.rotate = function(degree, maxDegree) {
this.css({ WebkitTransform: 'rotate(' + degree + 'deg)'});
this.css({ '-moz-transform': 'rotate(' + degree + 'deg)'});
// Animate rotation with a recursive call
rotation = setInterval(function() {
if (degree < (maxDegree/2)) {
$(this).rotate(++degree);
} else {
clearInterval(rotation);
}
},5);
};
}(jQuery));
我打电话这样说:
$('#test').live('mouseover',function() {
$(this).rotate(0, 360);
});
但它不火,这里是一个的jsfiddle: http://jsfiddle.net/neuroflux/8vZqr/
(注意,小提琴不会因为live()
而运行)
哎呀,我 - 我忘了把它变成SO。仍然不会触发:( –
@Neurofluxation:查看我的最新更新...它现在可以工作 –
完美!干杯费利克斯 –