I have successfully rotated a div using the following code snippet:
function AnimateRotate(d){
var elem = $("#arrow");
$({deg: 0}).animate({deg: d}, {
duration: 200,
step: function(now){
elem.css({
transform: "rotate(" + now + "deg)"
});
}
});
}
Now, I am encountering an issue when attempting to rotate the div back in the opposite direction. After the div has been rotated and I click on it again, it just repeats the same cycle of animation and ends up at its original position. However, my intention is for it to perform the same rotation but in the reverse direction.
To better illustrate my point, I have provided a link to a JSfiddle.
Visual representation: