javascript 未捕获的类型错误:未定义不是花式框的函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26135728/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 05:33:24  来源:igfitidea点击:

Uncaught TypeError: undefined is not a function for fancy box

javascriptjqueryfancybox

提问by Giant

$(".fancybox-effects-b").fancybox({
    openEffect  : 'none',
    closeEffect : 'none',
    closeClick : true,
    helpers : {
    title : {
        type : 'inside'
        }
    }
}); 

This is a code for fancy box i included the entire lib folder and source folder of fancy box but i still get Uncaught TypeError: undefined is not a functionin the $(".fancybox-effects-b").fancyboxwhat may be the cause of this what is the solution for this

这是看中框代码我看中包含框的整个lib文件夹和源文件夹,但我仍然得到Uncaught TypeError: undefined is not a function$(".fancybox-effects-b").fancybox东西可能是这个原因究竟是什么解决方案

UPDATE

UPDATE

got the code here

得到了这里的代码

this is all the script i used

这是我使用的所有脚本

    <link   type="text/css" rel="stylesheet" href="css/style.css">
    <script type="text/javascript"src="js/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="http://oap.accuweather.com/launch.js"></script>

<!-- Add fancyBox main JS and CSS files -->
    <!-- Add jQuery library -->
    <script type="text/javascript" src="lib/jquery-1.10.1.min.js"></script>

    <!-- Add mousewheel plugin (this is optional) -->
    <script type="text/javascript" src="lib/jquery.mousewheel-3.0.6.pack.js"></script>

    <!-- Add fancyBox main JS and CSS files -->
    <script type="text/javascript" src="source/jquery.fancybox.js?v=2.1.5"></script>
    <link rel="stylesheet" type="text/css" href="source/jquery.fancybox.css?v=2.1.5" media="screen" />

    <!-- Add Button helper (this is optional) -->
    <link rel="stylesheet" type="text/css" href="source/helpers/jquery.fancybox-buttons.css?v=1.0.5" />
    <script type="text/javascript" src="source/helpers/jquery.fancybox-buttons.js?v=1.0.5"></script>

    <!-- Add Thumbnail helper (this is optional) -->
    <link rel="stylesheet" type="text/css" href="source/helpers/jquery.fancybox-thumbs.css?v=1.0.7" />
    <script type="text/javascript" src="source/helpers/jquery.fancybox-thumbs.js?v=1.0.7"></script>

    <!-- Add Media helper (this is optional) -->
    <script type="text/javascript" src="source/helpers/jquery.fancybox-media.js?v=1.0.6"></script>
<!-- Add fancyBox main JS and CSS files --> 
<script type="text/javascript" src="js/js.js"></script>

<!--slider-->
    <script type="text/javascript" src="js/jssor.core.js"></script>
    <script type="text/javascript" src="js/jssor.utils.js"></script>
    <script type="text/javascript" src="js/jssor.slider.js"></script>
<!--slider end-->

回答by Nikola Loncar

Try

尝试

jQueryinsted $, and there are two jQuerylib loading!!!

jQueryinsted $,并且有两个jQuerylib加载!!!

 <script type="text/javascript"src="js/jquery-1.11.1.min.js"></script>

 <script type="text/javascript" src="lib/jquery-1.10.1.min.js"></script>

Remove one of those from header.

从标题中删除其中之一。

EDIT your script have to go like this in order to work:

编辑您的脚本必须像这样才能工作:

jQuery(document).ready(function($) {
    $(".fancybox-effects-b").fancybox({
        openEffect  : 'none',
        closeEffect : 'none',
        closeClick : true,
        helpers : {
        title : {
            type : 'inside'
        }
    }
}); 

});

});

回答by Shoaib Chikate

You have included 2 jQuery scripts. Remove one of them

您已包含 2 个 jQuery 脚本。删除其中之一

<script type="text/javascript" src="lib/jquery-1.10.1.min.js"></script>
<script type="text/javascript"src="js/jquery-1.11.1.min.js"></script> //remove anyone of them

Type in browser's console jQuery and check whether it give function or not.

输入浏览器的控制台 jQuery 并检查它是否提供功能。

Or call your script in onload or ready function()

或者在 onload 或 ready function() 中调用您的脚本

jQuery(document).ready(function($) {
    $(".fancybox-effects-b").fancybox({
        openEffect  : 'none',
        closeEffect : 'none',
        closeClick : true,
        helpers : {
        title : {
            type : 'inside'
        }
    }
});

Here $ or jQuery variable will be consider as jQuery object. Anyone and not two at a time

这里 $ 或 jQuery 变量将被视为 jQuery 对象。任何人,而不是一次两个

hence use one at a time instead of using two.

因此一次使用一个而不是两个。

jQuery(document).ready(function($) {
    jQuery(".fancybox-effects-b").fancybox({
        openEffect  : 'none',
        closeEffect : 'none',
        closeClick : true,
        helpers : {
        title : {
            type : 'inside'
        }
    }
});

回答by Manjar

Your jQuery reference is not working which makes fancybox doesnt work.

您的 jQuery 参考不起作用,这使得fancybox 不起作用。

Fix jQuery reference and everything should be alright

修复 jQuery 引用,一切都应该没问题