我知道我的文件链接正确,因为它显示在Chrome的检查员中。这是我的HTML:
<!DOCTYPE html>
<html>
<head>
<title>jQuery</title>
<script type='text/javascript' src='jquery-1.7.2.min.js'></script>
<script type='text/javascript' src='scripts/change.js'></script>
</head>
<body>
<p>
<button id="start">Start</button>
<button id="stop">Stop</button>
</p>
<p id="image">
<img src='images/image.jpg' alt="image" />
</p>
</body>
</html>jQuery:
$('#start').click(function() {
$('#image').slideToggle(3000);
});发布于 2012-08-14 18:53:18
您需要在$(document).ready()处理程序中包装完整的代码。因此,it确保,在整个资源加载完成后,代码将绑定到dom。
$(document).ready(function() {
$('#start').click(function() {
$('#image').slideToggle(3000);
});
});备注
检查外部JavaScript文件的路径是否为OK。
https://stackoverflow.com/questions/11958871
复制相似问题