Rotate div text after clicking on button using jquery and css

后端 未结 1 726
灰色年华
灰色年华 2020-12-02 02:42

I want to rotate div text after clicking on button using jquery and css

If user click on Rotate Left button then text rotate in Left side
or

相关标签:
1条回答
  • 2020-12-02 03:16

    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);
    });
    
    0 讨论(0)
提交回复
热议问题