最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Uncaught TypeError: Object #<HTMLDocument> has no method 'ready' - Stack Overflow

programmeradmin2浏览0评论

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.

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-ments" style="margin-top: 10px">
                <div class="left-side">
                    <p class="top-ment-title">Michigan</p>
                    <div class="top-ment-wrapper">
                        <div class="top-ment-header">
                            <span class="user-name">Andrew P.</span>
                            <div class="fix"></div>
                        </div>
                        <p class="top-ment-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-ment-title">Notre Dame</p>
                    <div class="top-ment-wrapper">
                        <div class="top-ment-header dispute-ment">
                            <span class="user-name">Jenny S.</span>
                            <div class="fix"></div>
                        </div>
                        <p class="top-ment-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-ment-title">Michigan</p>
                </div>
                <div class="right-side">
                    <p class="top-ment-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

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.

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-ments" style="margin-top: 10px">
                <div class="left-side">
                    <p class="top-ment-title">Michigan</p>
                    <div class="top-ment-wrapper">
                        <div class="top-ment-header">
                            <span class="user-name">Andrew P.</span>
                            <div class="fix"></div>
                        </div>
                        <p class="top-ment-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-ment-title">Notre Dame</p>
                    <div class="top-ment-wrapper">
                        <div class="top-ment-header dispute-ment">
                            <span class="user-name">Jenny S.</span>
                            <div class="fix"></div>
                        </div>
                        <p class="top-ment-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-ment-title">Michigan</p>
                </div>
                <div class="right-side">
                    <p class="top-ment-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

Share Improve this question edited Jun 16, 2012 at 2:57 Danconia asked Jun 14, 2012 at 23:50 DanconiaDanconia 5632 gold badges12 silver badges28 bronze badges 2
  • 3 You haven't included jQuery correctly. Triple check the location of jquery.js. – Andrew Whitaker Commented Jun 14, 2012 at 23:51
  • @AndrewWhitaker, I did not? If I link to sofiaandluis./luis/public/scripts/jquery.min.js I can see the jQuery file. Is that not it? – Danconia Commented Jun 14, 2012 at 23:55
Add a ment  | 

2 Answers 2

Reset to default 4

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.

You didn't reference jQuery successfully.

Check this:

alert(typeof $ == "undefined");
alert(typeof jQuery == "undefined");    

If those are true, jQuery was not loaded to the page.

Change:

<script type="text/javascript" src="public/scripts/jquery.min.js"></script>

To:

<script type="text/javascript" src="http://www.sofiaandluis./luis/public/scripts/jquery.min.js"></script>
发布评论

评论列表(0)

  1. 暂无评论