doujia4759 2017-10-25 12:03
浏览 127

点击按钮打开prettyphoto(多个图像)

I am using prettyphoto, in that i can able to open single image as a prettyphoto on a button click. But I need the mutiple images to be open as prettyphoto on a button click.

here is the code i'm used. In this $image_src_cb1 is an array.

<?php $html .= $button_class_wrapper_open . "<a class='" . $button_class . $button_animation_class . $prettyphoto_class . "' data-rel='" . $pretty_photo_rel . "' href='" . $image_src_cb1 . "' ><span class='cover_boxes_button_text text_wrap'> " . $link_label1 .'</span>'. $button_icon . "<span class='a_overlay'></span></a>" . $button_class_wrapper_close;

can anyone give me suggestion to open multiple images on button click.

  • 写回答

1条回答 默认 最新

  • dongshan7060 2018-05-18 14:53
    关注

    Using version: 3.1.5

    Add an identifier to each image. For example the rel attribute:

    <img src="image--1.jpg" rel="prettyPhoto[myGallery]" alt="">
    <img src="image--2.jpg" rel="prettyPhoto[myGallery]" alt="">
    <img src="image--3.jpg" rel="prettyPhoto[myGallery]" alt="">
    
    <button type="button" class="foo">Gallery</button>
    

    Pass the src attributes to prettyPhoto as an array:

    $('.foo').on('click', function() {
        var ImgArr = [];
    
        $('[rel="prettyPhoto[myGallery]"]').each(function() {
            var src = $(this).attr('src');
            ImgArr.push(src);
        });
        $.prettyPhoto.open(ImgArr);
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?