0
我正在制作一个Jquery幻灯片。它列出缩略图,当点击时,将大图像显示为覆盖图。为了将大拇指与大图像匹配,我将属性添加到每个缩略图和大图像。这些属性包含一个数字,它将每个拇指与其对应的大图像进行匹配。当一个幻灯片出现在页面上时,它可以工作。但是如果存在多个幻灯片,我希望它能够工作。Jquery:在多于一个div中的每个元素的集合
下面是添加属性,以拇指和大型图像的代码:
thumbNo = 0;
largeNo = 0;
$('.slideshow_content .thumbs img').each(function() {
thumbNo++;
$(this).attr('thumbimage', thumbNo);
$(this).attr("title", "Enter image gallery");
});
$('.slideshow_content .image_container .holder img').each(function() {
largeNo++;
$(this).addClass('largeImage' + largeNo);
});
这工作。为了使增量工作时,有一个页面上的两个幻灯片,我以为我可以在每个功能坚守此代码...
$('.slideshow').each(function() {
thumbNo = 0;
largeNo = 0;
$(this + '.slideshow_content .thumbs img').each(function() {
thumbNo++;
$(this).attr('thumbimage', thumbNo);
$(this).attr("title", "Enter image gallery");
});
$(this + '.slideshow_content .image_container .holder img').each(function() {
largeNo++;
$(this).addClass('largeImage' + largeNo);
});
});
这样做的问题是,incrimenting操作不会重置第二幻灯片div(.slideshow),所以我最终在第一个.slideshow div被编号为1,2,3等大拇指。第二个.slideshow div被编号为4,5,6等拇指。第二个.slideshow div中的数字重置并从1开始?
这真的很难简明扼要地解释。我希望有人得到这个要点。