Fancybox 2 Custom Titles and Captions [from A(title) and IMG(alt]

后端 未结 4 1157
北海茫月
北海茫月 2020-12-21 05:58

I\'m trying to use title and \"captions\" from image alt tags with fancybox 2... for some reason I can\'t seem this to work...

    $(\'.fancybox\').fancybo         


        
4条回答
  •  情书的邮戳
    2020-12-21 06:44

    If I understood right, you want fancybox title as a combination of the title attribute in the a tag + the alt attribute in the img tag.

    If the above is correct, then having a html like

    alt image 01
    

    the fancybox title should say "title anchor 01 alt image 01"

    you do that with this script:

    $(document).ready(function() {
     $(".fancybox").fancybox({
      helpers : {
       title: { type: 'inside'}
      },
      afterLoad: function(){
       this.title = this.title + ' ' + $(this.element).find('img').attr('alt');
      }
     }); // fancybox
    }); // ready
    

提交回复
热议问题