2

我有一张图像,我试图将其旋转 30 度并在页面上水平移动。但是,我认为我没有正确处理 jquery,因为我在 Firefox Web 控制台中遇到了几个错误。以下是错误:

[10:30:27.260] ReferenceError: jQuery is not defined @ file:///home/ladmin/Desktop/javascriptAnimations/jquery.rotate.1-1.js:1
[10:30:27.274] The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must to be declared in the document or in the transfer protocol. @ file:///home/ladmin/Desktop/javascriptAnimations/si110cockroach.html
[10:31:03.416] ReferenceError: $ is not defined @ file:///home/ladmin/Desktop/javascriptAnimations/si110cockroach.html:12

我在顶部包含了带有 jquery 源的脚本标签,如下所示:

<script language="javascript" type="text/javascript" src="jquery.rotate.1-1.js"></script>

这是我调用 jquery 的代码:

function moveLeft(object,x,y){
        $(object).rotateRight(30);
        object.style.right = x + "px";
        object.style.top   = y + "px";

        if (x < 0 || x > 1500 || y < 0 || y > 1500)
        {
            object.style.visibility="hidden";
        }
        else
        {               
            var t = setTimeout(function() { moveLeft(object,x+3,y+0); }, 5);
        }
    }

我没有正确包含源文件还是我没有调用 jquery 对?

4

1 回答 1

5

您必须在脚本之前包含jquery.min.jsjquery.rotate.1-1.js

<script language="javascript" type="text/javascript" src="jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="jquery.rotate.1-1.js"></script>
于 2012-07-19T14:41:57.287 回答