繁体   English   中英

如何停止此fancybox在加载时打开?

[英]How to stop this fancybox opening on load?

我试图弄清楚为什么此jQuery代码使fancybox图像在页面加载时打开,而不是等待用户单击它。 单击该如何打开它? 这是一个小提琴

<a class="fancybox" id="single_image" href="http://fancyapps.com/fancybox/demo/1_b.jpg" title="title" 
                  width="200">
  <img src="http://fancyapps.com/fancybox/demo/1_b.jpg"  width="300"  alt=""></a>

jQuery的

$(document).ready(function() {
    $("#single_image").fancybox({
        onComplete: function () {
            $("#fancybox-img").wrap($("<a />", {
                href: this.href, //or your target link
                target: "_blank"
            }));
        }
    }).trigger("click");
});

删除.trigger(“ click”);

$(document).ready(function() {
    $("#single_image").fancybox({
        onComplete: function () {
            $("#fancybox-img").wrap($("<a />", {
                href: this.href, //or your target link
                target: "_blank"
            }));
        }
    })
});

小提琴: http : //jsfiddle.net/j14gf3sv/4/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM