hey I’m trying to animate the rotation of a button 45 degrees every time it’s clicked, and I can’t get my function to work, this is what I have so far:
function increaseAngle(elem) {
var oldAngle = $(elem).data('angle');
var newAngle = oldAngle + 45;
$(elem)
.css("-webkit-transform", "rotateZ(" + newAngle + "deg)")
.data('angle', newAngle);
}
$(".info_btn")
.css("-webkit-transition", "-webkit-transform 0.25s ease-in-out")
.data('angle', 0);
.toggle(function() {
increaseAngle(this);
}, function() {
increaseAngle(this);
});
If you’re trying to chain your functions, that semicolon shouldn’t be there.
Your code works fine, you just need a minor adjustment to how you’re calling it. Toggle will hide the element, so use the click event instead.