javascript - jQuery 不能在我的网站上运行?

标签 javascript jquery html css

<分区>


关于您编写​​的代码问题的问题必须在问题本身中描述具体问题 — 并且包括有效代码 以重现它。参见 SSCCE.org寻求指导。

关闭 9 年前

我尝试在我的网站上使用 jQuery,但它似乎不起作用。我认为我做错了什么,所以我尝试将我完成的 codecademy 类(class)复制到测试站点上。这是代码:

HTML

<!DOCTYPE html>
<html>
    <head>
        <title>Test Codecademy Lesson</title>
        <link rel='stylesheet' type='text/css' href='stylesheet.css'/>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
        <script type='text/javascript' src='script.js'></script>
    </head>
    <body>
        <img src="http://i1061.photobucket.com/albums/t480/ericqweinstein/elevator.png"/>   
    </body>
</html>

CSS

body {
    margin: 0;
    padding: 0;
}
img {
position: absolute;
}

Javascript/jQuery

$(document).ready(function() {
    $('img').animate({top:'+=100px'},1000)
});


有人能告诉我为什么这段代码不起作用吗? 我的浏览器是 Chrome,我有最新版本。

最佳答案

你需要下载jquery库并保存你的本地文件你可以从这里下载

http://jqueryui.com/

你必须使用这个链接

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>

或缩小版

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>

http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js - 版本 1.9.1 系列,谷歌托管

你也可以引用这个

Is there a link to the "latest" jQuery library on Google APIs?

关于javascript - jQuery 不能在我的网站上运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19521092/

上一篇:html - 删除图像和容器之间的间隙

下一篇:javascript - Bootstrap 警报不起作用

相关文章:

javascript - 通过ajax Nodejs Express上传带有表单的文件

html - 我应该在 CSS 中选择哪个标签以及我应该暗示哪些 css 规则以便元素将出现在列中(大型菜单)

javascript - 制作一个简单但现代的搜索栏

jquery - 将 JQM 滑动事件添加到 ListView 链接

javascript - 按钮 mousedown 不会在断点处停止

jquery - 如何获取:remote => true working to update a part of the page?

javascript - Jquery 跟踪下拉菜单中的更改

javascript - ReactJS:如何在 JavaScript 中过滤数组以在 map 上显示特定图像

javascript - jQuery:输入的值不保存在变量中

javascript - React 组件中的一次性操作