jquery lightbox on dynamic image

◇◆丶佛笑我妖孽 提交于 2019-12-08 09:36:33

问题


I would like to use lightbox (pirobox) for dynamically generated images. I use standard method - load css, js files and add selector on element, but it doesnt work. Have you any experiencies with it?

I Also try

$('.pirobox').bind('click', function() {
   $('.pirobox').piroBox({
      my_speed: 400, 
      bg_alpha: 0.3, 
      slideShow : true, 
      slideSpeed : 4, 
      close_all : '.piro_close,.piro_overlay'
   });
});

回答1:


It is solved. Add this code after generating links.

$(document).find('a.lightbox').lightBox();



回答2:


Use live instead, it can be used for elements present now or future (in your case).

$('.pirobox').live('click', function() {
   $('.pirobox').piroBox({
      my_speed: 400, 
      bg_alpha: 0.3, 
      slideShow : true, 
      slideSpeed : 4, 
      close_all : '.piro_close,.piro_overlay'
   });
});


来源:https://stackoverflow.com/questions/3226900/jquery-lightbox-on-dynamic-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!