自动打开第一张Fancybox图片 [英] Open up first Fancybox picture automatically

查看:96
本文介绍了自动打开第一张Fancybox图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

点击链接后,我会从JSON get中引入一些图像,然后点击其中一张图片可以显示图库,但我希望第一张图像能够直接显示,加载JSON后的事件。这可能吗?

Upon clicking on a link, I am bringing in some images from a JSON get, and then when clicking on one of the pictures can get the gallery to appear, but I would like the first image to appear straight away, as an event once the JSON has been loaded. Is this possible?

我的代码是:

$("#json-get")
    .css("cursor","pointer")
    .click(function(){
        $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?",
            function(data){
                $.each(data.items, function(i,item){
                    $("<a/>").attr("rel", "group").addClass("json-im").appendTo("#imgs").attr("href", item.media.m).append(
                    $("<img/>")
                        .attr("src", item.media.m)
                    );
                });
                $("#imgs a").fancybox();
                // Load the first element
            });
});

非常感谢!

推荐答案

尝试添加:

  $("#imgs a:first").trigger('click');

创建fancybox后。

after you create the fancybox.

这篇关于自动打开第一张Fancybox图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆