JSFiddle - React, Tailwind, and code Playground
HTML
<div id="test" style="background-color: silver; width: 128px; height: 128px;"> </div>
CSS
* { padding: 0px; margin: 0px; }
JavaScript
(function ($) { //jQuery plugin extension
$.fn.rotate = function(degree, maxDegree) {
this.css({ WebkitTransform: 'rotate(' + degree + 'deg)'});
this.css({ '-moz-transform': 'rotate(' + degree + 'deg)'});
// Animate rotation with a recursive call
var $self = this;
var rotation = setInterval(function() {
if (degree < (maxDegree/2)) {
$self.rotate(++degree);
} else {
clearInterval(rotation);
}
},5);
};
}(jQuery));
$('#test').live('mouseover',function() {
$(this).rotate(0, 360);
});