Javascript Ajax jQuery Html PHP Example Quiz New MORE
Need a Website Or Web Application Or Any Help In Code As Per Your Budget, Contact Us: +91 9437911966 (Whatsapp)

How to rotate image in jQuery with demo

 
<!Doctype html>
<html>
<head>
    <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
    <br>
    <div class="w3-center"><img src="php.jpg" id="rotate-image" height="150px" width="150px" /></div>
    <br>
    <div class="w3-center">
        <input type="button" class="w3-btn w3-green" value="90" onClick="rotateImage(this.value);" />
        <input type="button" class="w3-btn w3-green" value="-90" onClick="rotateImage(this.value);" />
        <input type="button" class="w3-btn w3-green" value="180" onClick="rotateImage(this.value);" />
        <input type="button" class="w3-btn w3-green" value="360" onClick="rotateImage(this.value);" />
    </div>
    <script>
        function rotateImage(degree) {
            $('#rotate-image').animate({
                transform: degree
            }, {
                step: function(now, fx) {
                    $(this).css({
                        '-webkit-transform': 'rotate(' + now + 'deg)',
                        '-moz-transform': 'rotate(' + now + 'deg)',
                        'transform': 'rotate(' + now + 'deg)'
                    });
                }
            });
        }
    </script>
</body>
</html>

Demo