Fancybox :TypeError: $(…).Fancybox is not a function

前端 未结 2 2011
暖寄归人
暖寄归人 2021-02-11 03:28

I want to open a fancy box, But it give a Type error, can you please help me to solve this problem

view page contain following code



        
相关标签:
2条回答
  • 2021-02-11 03:52
    <script type="text/javascript">
    var $= jQuery.noConflict();
    

    noconflict in your jQuery in a single page may be this answer will help you. and one more thing use highest version of a javascript file like only use jquery 1.3.min.js between jquery 1.3.min.js and jquery 1.3.5.min.js

    0 讨论(0)
  • 2021-02-11 04:04

    The "no conflict" trick helps. To use an author's existing plugin code, you can wrap it in an IIFE:

    // IIFE passing in jQuery.noConflict()
    (function(jQuery){
    
         // Original author's plugin code
         // ...
         jQuery("a.fancybox").fancybox({ ... }
         // ...
    
    })(jQuery.noConflict());
    

    I've had to do this for two WordPress plugins to get them working with Firefox: Easy FancyBox and FancyBox for Wordpress. I hope this helps.

    0 讨论(0)
提交回复
热议问题