美文网首页
JS实现图片旋转90度

JS实现图片旋转90度

作者: 玛瑙鑫 | 来源:发表于2020-07-28 11:22 被阅读0次
<!DOCTYPE html>
<html>
<head>
    <title>图片旋转</title>
    <script>
        window.onload = function(){ 
            var current = 0;
            document.getElementById('rotate').onclick = function(){
                current = (current+90)%360;
                this.style.transform = 'rotate('+current+'deg)';
            }
        };
    </script>
</head>
<body>
    <img id ="rotate" src="">
</body>

相关文章

网友评论

      本文标题:JS实现图片旋转90度

      本文链接:https://www.haomeiwen.com/subject/gxcfrktx.html