如何使用jquery旋转插件旋转图像?

时间:2022-08-24 08:58:04

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

如何使用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!

大多数浏览器都支持其他方法,谢谢!

3 个解决方案

#1


23  

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.

你有一个关于jQuery和jQuery插件的404。因此,您的页面抛出了JavaScript错误,$未定义。

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调试技巧。快速搜索发现这篇文章看起来像是一个开始的好地方:

#2


7  

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>

#3


3  

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

修复jquery包含问题后,您可以修复脚本。你的语法错了:这是修复:

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

#1


23  

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.

你有一个关于jQuery和jQuery插件的404。因此,您的页面抛出了JavaScript错误,$未定义。

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调试技巧。快速搜索发现这篇文章看起来像是一个开始的好地方:

#2


7  

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>

#3


3  

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

修复jquery包含问题后,您可以修复脚本。你的语法错了:这是修复:

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