使用js实现点击图片 旋转

var r = 0;
    window.onload = function(){
        var current = 0;
        document.getElementById('img1').onclick = function(){
            current = (current+90)%360;
            this.style.transform = 'rotate('+current+'deg)';
        }
    };
<img id = "img1" style="display: inline-block;">
document.getElementById('img1').src ="${pageContext.request.contextPath}/images/"+YJMC;

给img标签添加点击事件,如上第一个方法。

猜你喜欢

转载自blog.csdn.net/feng_qin19936/article/details/81261671