jquery rotate image onclick

前端 未结 7 712
难免孤独
难免孤独 2020-12-17 10:30

I am trying to achieve this (90 degree rotation), but it fails without errors. This image is within a TAG where it has already a toggle jque

7条回答
  •  清歌不尽
    2020-12-17 11:16

    This will enable you to perform an additional rotation of each clik

    var degrees = 0;
    $('.img').click(function rotateMe(e) {
    
        degrees += 90;
    
        //$('.img').addClass('rotated'); // for one time rotation
    
        $('.img').css({
          'transform': 'rotate(' + degrees + 'deg)',
          '-ms-transform': 'rotate(' + degrees + 'deg)',
          '-moz-transform': 'rotate(' + degrees + 'deg)',
          '-webkit-transform': 'rotate(' + degrees + 'deg)',
          '-o-transform': 'rotate(' + degrees + 'deg)'
        }); 
    
    });     
    

    https://jsfiddle.net/Lnckq5om/1/

提交回复
热议问题