因此,我得到了以下HTML和jQuery代码,每当我试图加载页面时,Firebug都会给我一个'ReferenceError:$ is undefined‘错误;因此,jQuery代码无法工作。我在Mavericks上使用Coda 2.0.9。我在加载jQuery UI库之前加载了jQuery库(使用Google CDN),在我编写的脚本之前也加载了这两个库。在Firebug的Net部分,它显示的唯一请求是来自Google字体的字体。这只是一个首页,所以代码很少。对于我的生活,我不能弄清楚这一点,所以任何帮助都会非常感谢。
<meta name="description" content="Description here" >
<title>This site is being updated</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<link href='http://fonts.googleapis.com/css?family=Signika+Negative' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="main.css">
<script type="text/javascript" src="jquery.js"></script> <h1 class="maintitle"> This site is getting cleared up! </h1>
<img class="construction" src="images/construction_800.png">
<div id='wrapper' style='text-align:center;width:auto; margin: 0px 90px'>
<div style='float:left;width:50%'>
<strong>Office 1</strong> <br>
p. xxx.xxx.xxxx <br>
f. xxx.xxx.xxxx
</div>
<div style='float:right;width:50%'>
<strong>Office 2</strong> <br>
p. xxx.xxx.xxxx <br>
f. xxx.xxx.xxxx
</div>
</div>
<p class="comeback"><strong>Please check back soon for the updated site</strong></p>
</body>
jQuery:
$(document).ready(function() {
$(".maintitle", ".construction", "div", ".comeback").fadeIn("slow");
});发布于 2013-11-18 07:16:47
您在头文件中加载了两次Jquery。
删除最后一行
<script type="text/javascript" src="jquery.js"></script>实际问题是与jQuery使用的$处理程序存在冲突。
如果是这样,像@Choineck这样将$更改为jQuery应该是可行的。
发布于 2013-11-18 07:20:28
jQuery(document).ready(function($) {
$(".maintitle", ".construction", "div", ".comeback").fadeIn("slow");
});发布于 2013-11-18 07:24:35
我认为问题在于您从ajax.google获取jQuery有一点延迟,但您也可以尝试如下所示
<script language="javascript" type="text/javascript">
$j = jQuery.noConflict();
</script>然后
$j("...")https://stackoverflow.com/questions/20037477
复制相似问题