Howto rotate image using jquery rotate plugin?

前端 未结 3 2135
夕颜
夕颜 2020-12-28 21:46

How do you rotate an image using jQuery-rotate plugin?

I have tried the following and it doesn\'t seem to work:





        
相关标签:
3条回答
  • 2020-12-28 22:05

    Your logic for rotating the image is right. It will work if executed when the document is ready.

    <script type="text/javascript">
    //<![CDATA[
        var angle = 1;
    
        $(document).ready(function() {
            setInterval(function() {
                $("#pic").rotate(angle);
                /* angle += 1; Increases the rotating speed */
            }, 100);
        });
    //]]>
    </script>
    
    0 讨论(0)
  • 2020-12-28 22:11

    You've got a 404 on jQuery and the jQuery plugin. Because of that, your page is throwing a JavaScript error, that $ is not defined.

    You need to learn basic JavaScript debugging techniques. A quick search found this article that looks like a good place for you to start:

    • JavaScript Debugging Techniques with Firebug
    0 讨论(0)
  • 2020-12-28 22:13

    Once you fix your jquery include issues, you can fix your script. Your syntax is wrong: Here is the fix:

    <script type="text/javascript">
    //<![CDATA[
        var angle = 1;
    
        $(document).ready(function(angle) {
            setInterval(function(angle) {
                    $("#pic").rotate(angle);
                    /* angle += 1; Increases the rotating speed */
            }, 100);
        });
    //]]>
    </script>
    
    0 讨论(0)
提交回复
热议问题