1php
先看一下文档
2html
修改html
这里用箭头指向了三个地方ide
第一个是id:这个值是须要跟随id的变化而变化,不然就只有第一个列表能够点击,其余的就不能够动画
第二个就是onclick:这个事件须要把对象自己当作参数传递过去this
3url
js代码
js这里就是获取一个父级的属性id值,而后传递给photos便可spa
4.net
效果图
补充代码code
<td> <div id="layer-photos-demo{$v['ft_id']}" class="layer-photos-demo"> <?php foreach($v['ftp_image'] as $v1) :?> <img layer-src="{$v1}" src="{$v1}" alt="" title=""> <?php endforeach;?> </div> </td>
//调用示例 function photos(){ layer.photos({ photos: '#layer-photos-demo' ,anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0以前的版本用shift参数) }); } $(".layer-photos-demo").click(function(){ var imgArry = []; var id = $(this).attr('id'); $("#"+id).find("img").each(function(){ imgArry.push({"src": $(this).attr("src")}) }) layer.photos({ photos: { "title": "", //相册标题 "id": 123, //相册id "start": 0, //初始显示的图片序号,默认0 "data": imgArry } //格式见API文档手册页 ,anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0以前的版本用shift参数) }); })