How do I make fancybox href dynamic?

后端 未结 5 451
北海茫月
北海茫月 2020-11-30 11:01

I have the following fancybox code:

$(\'.fancybox\').fancybox({
             \'autoScale\' : false,
             \'href\' : $(\'.fancybox\').attr(\'id\'),
           


        
5条回答
  •  温柔的废话
    2020-11-30 11:10

    You can iterate over your collection of .fancybox items and grab the id.

    $('.fancybox').each(function(){
        $(this).fancybox({
                 'autoScale' : false,
                 'href' : $(this).attr('id'),
                 'type':'iframe',
                 'padding' : 0,
                 'closeClick'  : false,
                 //some other callbacks etc
        });
    });
    

提交回复
热议问题