Rotate div text after clicking on button using jquery and css

Try this:

Demo: http://jsfiddle.net/ehec1gun/

var rotation = 0;

jQuery.fn.rotate = function(degrees) {
    $(this).css({'-webkit-transform' : 'rotate('+ degrees +'deg)',
                 '-moz-transform' : 'rotate('+ degrees +'deg)',
                 '-ms-transform' : 'rotate('+ degrees +'deg)',
                 'transform' : 'rotate('+ degrees +'deg)'});
};

$('#btnRotateRight').click(function() {
    rotation += 5;
    $('.rotate').rotate(rotation);
});

$('#btnRotateLeft').click(function() {
    rotation -= 5;
    $('.rotate').rotate(rotation);
});

Leave a Comment