我最近在学习javascript + jquery,在尝试将jquery导入html时遇到问题。
我从互联网上获得了以下代码,而我尝试从
更改行<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script>
到
<script type='text/javascript' src='jquery.js'></script>
它不起作用,脚本不会执行。
我确信文件“jquery.js”与html文件是相同的文件夹,而jquery.js是从http://jquery.com/download/下载的(我确实将文件名更改为'jquery.js'而不是它的原始长名称)
我可能犯了什么错误?
Html代码:
<!DOCTYPE html>
<html>
<head>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("div").animate({left:'250px'});
});
});
</script>
</head>
<body>
<button>Start Animation</button>
<p>By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!</p>
<div style="background:#98bf21;height:100px;width:100px;position:absolute;">
</div>
</body>
</html>
答案 0 :(得分:1)
对我来说,这在chrome中运行良好:
<!DOCTYPE html>
<html>
<head>
<script src='jquery.js'></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("div").animate({left:'250px'});
});
});
</script>
</head>
<body>
<button>Start Animation</button>
<p>By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!</p>
<div style="background:#98bf21;height:100px;width:100px;position:absolute;">
</div>
</body>
</html>
使用此版本的Jquery http://code.jquery.com/jquery-1.8.2.min.js
的本地副本