加载了JQuery和Colorbox,但“colorbox不是一个函数”。 [英] JQuery and Colorbox loaded but "colorbox is not a function"

查看:79
本文介绍了加载了JQuery和Colorbox,但“colorbox不是一个函数”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经检查过是否加载了jQuery并且加载了colorbox脚本并且它们都已正确加载(我使用.getScript来查看colorbox是否正确加载并获得了肯定的结果)。然而,该功能不加载colorbox,Firebug说$(...)。colorbox不是一个函数。用来工作的代码,但我不知道我做了什么打破它。这是标题:

I have checked to see if both jQuery is loaded and the colorbox script is loaded and they both have been loaded correctly (I used .getScript to see if colorbox loaded correctly and I get a positive result). However the function does not load colorbox and Firebug says "$(...).colorbox is not a function". The code used to work but I'm not sure what I did to break it. Here's the header:

<!DOCTYPE html>
<head>
<link rel="stylesheet" href="colorbox.css"/>
<script src="Scripts/jquery.colorbox.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script src="Scripts/scripts.js"></script>
<script>

$(document).ready(function(){
    $(".popup").colorbox({transition: "elastic", opacity: 0.5, speed: 350});
    var panels = $('.accordionButton > .accordionContent').hide();
    $("div.accordionButton").click(function(){
        panels.slideUp();           
        $(this).parent().next().slideDown();
        return false
    });

});
</script>
</head>

我已多次检查以确保脚本位于正确的目录中。以下是链接:

I have checked several times to make sure the script is located in the correct directory. Here is the link:

<div id='supermenu'><table><tr><td><a href='login.php?lang=en' class='popup'>Login</a></td><td> or </td><td><a href='register.php?lang=en'> Register </a></tr></td></table></div>


推荐答案

您需要在之后引用colorbox文件 jquery文件。像这样:

You need to reference the colorbox file after the jquery file. Like this:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script src="Scripts/jquery.colorbox.js"></script>
<script src="Scripts/scripts.js"></script>

顺便提一下大多数jquery插件的情况。

That is the case for most jquery plugins by the way.

这篇关于加载了JQuery和Colorbox,但“colorbox不是一个函数”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆