Fancybox无法完美运行

huangapple go评论70阅读模式
英文:

Fancybox not running perfectly

问题

I have written the following code in my project

$('[data-fancybox]').fancybox({
    // Options will go here
    infobar: false,
    buttons : [
        "zoom",
        "slideShow",
        //"fullScreen",
        //"download",
        "thumbs",
        "close"
    ],
    wheel : false,
    transitionEffect: "slide",
    // thumbs: false,
 
    // hash            : false,
    
    // keyboard        : true,
    toolbar: true,
    // animationEffect : false,
    // arrows          : true,
    clickContent: false,
    afterLoad: function() {
               if ($('.fancybox-button--play').hasClass("fancybox-button--pause")) {
            $('.fancybox-button--play').trigger('click');
        }
        }
    });

That code is not executing... however, When I execute it in console it perfectly works... What I am doing wrong?

英文:

I have written the following code in my project

$('[data-fancybox]').fancybox({
        // Options will go here
        infobar: false,
        buttons : [
            "zoom",
            "slideShow",
            //"fullScreen",
            //"download",
            "thumbs",
            "close"
        ],
        wheel : false,
        transitionEffect: "slide",
        // thumbs: false,
     
        // hash            : false,
        
        // keyboard        : true,
        toolbar: true,
        // animationEffect : false,
        // arrows          : true,
        clickContent: false,
        afterLoad: function() {
                   if (!$('.fancybox-button--play').hasClass("fancybox-button--pause")) {
                $('.fancybox-button--play').trigger('click');
            }
            }
        });

That code is not executing... however, When I execute it in console it perfectly works... What I am doing wrong?

答案1

得分: 0

请尝试在 "$(document).ready()" 下加载您的脚本。

英文:

Please try to load your script under "$( document ).ready()"

huangapple
  • 本文由 发表于 2023年2月8日 19:08:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/75384905.html