javascript 未捕获的类型错误:对象 #<HTMLDocument> 没有方法“准备好”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11042905/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uncaught TypeError: Object #<HTMLDocument> has no method 'ready'
提问by Danconia
I have been trying to figure out why I am getting this problem and cannot figure it out. I am guessing it has to do with the libraries added but I am a newby and have spent like 2 days trying different things. The problem here is for the function calling the fancybox, but it happens whenever I call the document.ready.
我一直在试图弄清楚为什么我会遇到这个问题并且无法弄清楚。我猜这与添加的库有关,但我是新手,花了大约 2 天时间尝试不同的东西。这里的问题是调用fancybox 的函数,但是每当我调用document.ready 时它就会发生。
Here is the code:
这是代码:
<head>
<script type="text/javascript" src="public/scripts/jquery.min.js"></script> <!-- 1.7.2 -->
<script src="public/scripts/applicat.js" type="text/javascript"></script>
<!--Add link fancybox-->
<script type="text/javascript" src="public/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" href="public/fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen" />
<script type="text/javascript">
$(document).ready(function() {
$("#add-iframe").fancybox({
'hideOnContentClick': true
});
});
</script></head>
<section id="top-comments" style="margin-top: 10px">
<div class="left-side">
<p class="top-comment-title">Michigan</p>
<div class="top-comment-wrapper">
<div class="top-comment-header">
<span class="user-name">Andrew P.</span>
<div class="fix"></div>
</div>
<p class="top-comment-content">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer</p>
</div>
</div>
<div class="right-side">
<p class="top-comment-title">Notre Dame</p>
<div class="top-comment-wrapper">
<div class="top-comment-header dispute-comment">
<span class="user-name">Jenny S.</span>
<div class="fix"></div>
</div>
<p class="top-comment-content">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer</p>
</div>
</div>
<div class="fix"></div>
</section>
<!-- Articles -->
<section id="top-resources" style="display:none; margin-top:10px">
<a id="add-iframe" href="add-link.html" class="top-add-link">Add Link</a>
<div class="left-side">
<p class="top-comment-title">Michigan</p>
</div>
<div class="right-side">
<p class="top-comment-title">Notre Dame</p>
</div>
<div class="fix"></div>
</section>
</div>
<script type="text/javascript" charset="utf-8">
jQuery().ready(function() {
jQuery("#discussion-sections > nav ul").tabs("#discussion-sections > section");
});
</script>
Thanks for your help! Luis
谢谢你的帮助!路易斯
回答by raina77ow
You load Modernizr right after jQuery library somehow (in applicat.js), so $
variable gets rewritten. Use jQuery in 'noConflict' mode, or use Modernizr to load jQuery as described here.
您以某种方式(在 applicat.js 中)在 jQuery 库之后立即加载 Modernizr,因此$
变量会被重写。使用jQuery在“ noConflict”模式,或使用Modernizr的描述来加载jQuery的这里。
回答by gdoron is supporting Monica
You didn't reference jQuery successfully.
您没有成功引用 jQuery。
Check this:
检查这个:
alert(typeof $ == "undefined");
alert(typeof jQuery == "undefined");
If those are true, jQuery was not loaded to the page.
如果这些都是真的,jQuery 没有加载到页面。
Change:
改变:
<script type="text/javascript" src="public/scripts/jquery.min.js"></script>
To:
到:
<script type="text/javascript" src="http://www.sofiaandluis.com/luis/public/scripts/jquery.min.js"></script>