I would like to initialize prettyPhoto plugin for multiple galleries on one page so they can be shown separately. My idea was to go through all the divs which contain pictures and initialize new prettyPhoto for all images in that div. But val is apparently some kind of object and I am not able to call any functions on it. Is there a way how to do what I need?

 $(document).ready(function() {
     $.each($(".gallery"), function(i, val) {
         $(val).find("img").prettyPhoto({}); //init prettyPhoto plugin
     });
 });

P.S. Sorry for lame question I suppose it's basic stuff.

有帮助吗?

解决方案

I finally found the solution in case anybody is interested.

 $(document).ready(function(){
        $.each($(".gallery"), function(i, val) {
            var queryString = ".gallery:nth(" + i + ") a[rel^='prettyPhoto']";
            $(queryString).prettyPhoto({animation_speed:'normal',theme:'light_square', social_tools: false});
        });
    });
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top