I'm trying to rotate an element with jquery and then I want to do something else when its done. The rotate is working but why not the alert?
see jsfiddle: JSFiddle
HTML:
<div class="square">click me</div>
CSS:
.square{
background:red;
height:100px;
width:100px;
cursor:pointer;
}
JS:
$('.square').click(function () {
rotate($(this), -180, 1000);
});
function rotate(element, degrees, speed) {
element.animate({ borderSpacing: degrees }, {
step: function (now, fx) {
$(this).css('-webkit-transform', 'rotate(' + now + 'deg)');
$(this).css('-moz-transform', 'rotate(' + now + 'deg)');
$(this).css('transform', 'rotate(' + now + 'deg)');
},
duration: speed
}, function () {
alert("I'm done");
});
}