Javascript HTML+;jQuery结果显示在空白页中
我在实现jQuery时遇到了困难,特别是在复制方面。我从中了解到,引用jQuery.js的Javascript HTML+;jQuery结果显示在空白页中,javascript,jquery,jquery-ui-accordion,Javascript,Jquery,Jquery Ui Accordion,我在实现jQuery时遇到了困难,特别是在复制方面。我从中了解到,引用jQuery.js的需要放在引用本地JavaScript文件的之前,以便$(document.ready()待识别 因此,这里是index.html: <!DOCTYPE html> <html> <head> <title>Behold!</title> <link rel='stylesheet' type='text
需要放在引用本地JavaScript文件的
之前,以便$(document.ready()代码>待识别
因此,这里是index.html:
<!DOCTYPE html>
<html>
<head>
<title>Behold!</title>
<link rel='stylesheet' type='text/css' href='http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css'/>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js" type="text/javascript"></script>
<script type='text/javascript' src='index.js'></script>
</head>
<body>
<div id="menu">
<h3>jQuery</h3>
<div>
<p>jQuery is a JavaScript library that makes your websites look absolutely stunning.</p>
</div>
<h3>jQuery UI</h3>
<div>
<p>jQuery UI includes even more jQuery goodness!</p>
</div>
<h3>JavaScript</h3>
<div>
<p>JavaScript is a programming language used in web browsers.</p>
</div>
</div>
</body>
</html>
在Chrome和IE中,这都显示为一个完全空白的页面,没有jQueryaccordion
或任何文本的痕迹。
如果我忽略了什么,请告诉我-我真的很感谢你的帮助。谢谢 这是:
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.j" type="text/javascript"></script>
应该是这样的:
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js" type="text/javascript"></script>
我不知道这个错误是否只是复制粘贴的错误,但是文件扩展名不正确(应该是“js”而不是“j”)
此外,您不包括jQuery本身(仅包括jQuery UI)
使用以下头部区域:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js" type="text/javascript"></script>
<script type='text/javascript' src='index.js'></script>
这些对我来说很有用。您在src
链接中缺少了一个“s”。它应该是jquery-ui.min.js更重要的是,查看web检查器,在FireFox中,您可以使用Firebug,在Chrome中,只需在IE的开发工具中按F12即可。如果web inspector
中的控制台发现无法加载的资源,它将始终抛出一个错误。打字错误实际上是我的错,我在复制和粘贴之前不小心删除了“s”。不幸的是,这不是问题所在。谢谢你的帮助。事实上,这就是我所说的:“http:”这就是“http”。非常感谢!这一点我当然忘了做——再加上上面Borniet的回答,在每个链接之前加上“http:”,这就行了!谢谢你的帮助!实际上,它应该在没有“http:”(由谷歌提出)的情况下工作。如果缺少协议,浏览器将使用主页上的协议(就像缺少域时使用域一样)。这样做的优点是,它也适用于https,无需更改。因此,唯一的错误是缺少的“s”和jQuery本身的include。
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js" type="text/javascript"></script>
<script type='text/javascript' src='index.js'></script>