Open up first Fancybox picture automatically

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?

My code is:

                $.each(data.items, function(i,item){
                    $("<a/>").attr("rel", "group").addClass("json-im").appendTo("#imgs").attr("href",
                $("#imgs a").fancybox();
                // Load the first element

Many Thanks!



Try adding:

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

after you create the fancybox.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.