gpt4 book ai didi

jquery - JavaScript 错误 : jQuery is not defined

转载 作者:行者123 更新时间:2023-11-28 04:03:54 25 4
gpt4 key购买 nike

<html>
<head><title>test</title>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">
</script>
<!-- ERROR IS HERE the jquery is not being loaded -->

<script type="text/javascript" src="js/jquery.prettyPhoto.js">
</script>
<link rel="stylesheet" href="css/prettyPhoto.css" type="text/css"
media="screen" charset="utf-8" />
</head>
<body>
<a title="Despicable Me" rel="prettyPhoto[movies]"
href="http://trailers.apple.com/mymovie.mov?width=640&height=360">
<img src="images/thumbnails/quicktime-logo.gif" alt="Despicable Me"
width="50" />
</a>
<a title="Despicable Me" rel="prettyPhoto[movies]"
href="ai.mov?width=640&height=360">
<img src="images/thumbnails/quicktime-logo.gif"
alt="Despicable Me" width="50" />
</a>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("a[rel^='prettyPhoto']").prettyPhoto();
});
</script>
</body>
</html>

当我在 firefox 中加载此 html 时,错误控制台返回错误:

jQuery is not defined. 

html文件、js文件、css文件都在同一个文件夹下。我做错了什么?

最佳答案

我想你是在本地运行的。 (注意:不是localhost,是你打开本地的html文件)

如果在本地运行,那么 //ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js 表示 file:///ajax .googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js

所以你需要指定http://

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>

但是一旦您将页面上传到服务器,只需使用 // 就可以了,这是最佳实践。

关于jquery - JavaScript 错误 : jQuery is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12894523/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com