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

前端 未结 2 2015
暖寄归人
暖寄归人 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 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.

提交回复
热议问题