Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为下一个和上一个功能分组fancybox项_Javascript_Jquery_Fancybox - Fatal编程技术网

Javascript 为下一个和上一个功能分组fancybox项

Javascript 为下一个和上一个功能分组fancybox项,javascript,jquery,fancybox,Javascript,Jquery,Fancybox,所以fancybox插件在我的网站上工作,但只针对单个图像,所以我无法在它们之间滚动,或者切换到下一个prev按钮。我知道fancybox需要查看组才能启用此功能,但我被困在这里,仍然只能获取单个图像。以下是我的jQuery代码段和HTML结构: 非常感谢你的帮助 $('dl.gallery-item').each(function(index) { var rel = "group"; // +$(this).attr('id'); $('.gallery-item a').a

所以fancybox插件在我的网站上工作,但只针对单个图像,所以我无法在它们之间滚动,或者切换到下一个prev按钮。我知道fancybox需要查看组才能启用此功能,但我被困在这里,仍然只能获取单个图像。以下是我的jQuery代码段和HTML结构:

非常感谢你的帮助

$('dl.gallery-item').each(function(index) {
    var rel = "group"; // +$(this).attr('id');
    $('.gallery-item a').addClass('fancybox').attr('rel', rel);

});
$('.fancybox').fancybox(); 

<div id="gallery-1" class="gallery galleryid-15 gallery-columns-4 gallery-size-thumbnail">
      <dl class="gallery-item">
            <dt class="gallery-icon landscape">
                <a href="//localhost:3000/path-to-image" class="fancybox" rel="group"><img width="253" height="164" src="path-to-image" class="attachment-thumbnail size-thumbnail" alt=""></a>
            </dt></dl><dl class="gallery-item">
            <dt class="gallery-icon landscape">
                <a href="//localhost:3000/path-to-image" class="fancybox" rel="group"><img width="253" height="164" src="path-to-image" class="attachment-thumbnail size-thumbnail" alt=""></a>
            </dt></dl><dl class="gallery-item">
            <dt class="gallery-icon landscape">
                <a href="//localhost:3000/path-to-image" class="fancybox" rel="group"><img width="253" height="164" src="path-to-image" class="attachment-thumbnail size-thumbnail" alt=""></a>
            </dt>
      </dl>
</div>
$('dl.gallery item')。每个(函数(索引){
var rel=“group”//+$(this.attr('id');
$('.gallery项目a').addClass('fancybox').attr('rel',rel);
});
$('.fancybox').fancybox();

这是您的HTML,带有一个正常工作的Fancybox实现:

这是使用最新的Fancybox版本3.0.47

基本上,唯一的变化不是使用
rel
,而是使用
data-fancybox
进行分组

如果你不能让它工作,编辑我的小提琴和显示你的代码到底是什么样子


希望这有帮助

嗯..谢谢..是data fancybox attr,你挽救了这一天:)