views:

25897

answers:

6

How do you rotate an image using jquery (www.jquery.com) rotate plugin (http://code.google.com/p/jquery-rotate/)?

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!

+11  A: 

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 these articles that look like a good place for you to start:

http://www.developertutorials.com/tutorials/javascript/javascript-debugging-techniques-with-firebug-8-04-20/page1.html

http://javascript.internet.com/debug-guide.html

mqsoh
+2  A: 

Get fireBug for Firefox

+4  A: 

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>
jvan
A: 

Sorry,

Its not working..!

kwaxy
A: 

Unfortunately I am not spesialist in plugins. Is possibility to solve the problem with php script help? May you try to use php tutorials.

Lime
how is this even a little bit helpful?He wants to use jQuery - php shouldn't even come into this.
alex
A: 

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>
Spencer