Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Howto rotate image using jquery rotate plugin?

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

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

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>View Photo</title>
<script type="text/javascript" src="scripts/jquery.js"></script>
<script type="text/javascript" src="scripts/jquery.rotate.1-1.js"></script>
<script type="text/javascript">
var angle = 0;
setInterval ( function (e) {
    rotate();
}, 100 );
function rotate() {
    angle = angle + 1;
    $('#pic').rotate(angle);
}
</script>
</head>
<body>
<img border="0" src="player.gif" name="pic" id="pic">
</body>
</html>

Other methods that are supported by most browsers are wanted too, thanks!

like image 709
Tom Avatar asked Dec 13 '08 22:12

Tom


2 Answers

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
like image 115
mqsoh Avatar answered Sep 30 '22 02:09

mqsoh


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>
like image 21
jvan Avatar answered Sep 30 '22 04:09

jvan