I have a button that I’d like to rotate 45 degrees when it’s clicked, and when it’s clicked again it rotates 45 degrees again. I can’t use a style sheet and had been looking at this solution because it used only JavaScript http://jsfiddle.net/7b4VZ/3/ and was wondering if it could be set up as a class, again only using JavaScript that I can then set up as a toggle class with jQuery?
Code of fiddle:
var img = document.images[0];
img.style.setProperty("-webkit-transition", "left 2s linear");
var slide = function(){
img.style.setProperty("left", "200px");
setTimeout(function(){
img.style.setProperty("left", "0px");
setTimeout(slide,2000);
},2000);
}
slide();
You can use CSS transforms for the rotation: http://jsfiddle.net/antishok/7b4VZ/60/