rid*_*l53 2 javascript jquery jquery-plugins
我有一个图像,我试图旋转30度并在页面上水平移动.但是,我不认为我正在处理jquery,因为我在Firefox Web Console中遇到了几个错误.以下是错误:
[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
Run Code Online (Sandbox Code Playgroud)
我在顶部包含了jquery源代码的脚本标记,如下所示:
<script language="javascript" type="text/javascript" src="jquery.rotate.1-1.js"></script>
Run Code Online (Sandbox Code Playgroud)
这是我调用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);
}
}
Run Code Online (Sandbox Code Playgroud)
我没有正确包含源文件或者我没有正确调用jquery吗?
您必须在脚本之前包含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>
Run Code Online (Sandbox Code Playgroud)