图像缩略图库中的“下一个”和“上一个”按钮中的“问题”

Issue in Image Thumbnail Gallery next and prev buttons

本文关键字:上一个 下一个 按钮 问题 图像 略图      更新时间:2023-09-26

我的实际需求是最初我需要显示3张缩略图。当我点击next时,接下来的三个新缩略图应该会显示出来。如果您引用此链接http://www.frontendwebhelp.com/javascript/jquery-photo-gallery.php

这正是我所需要的。在这里,下一个和上一个按钮的功能对于缩略图和较大的图像是不同的。

我不应该使用任何类型的旋转木马插件来获得这种效果。

这是我试过的。

http://jsfiddle.net/L7yKp/37/

我需要一些帮助。

请参阅http://jsfiddle.net/L7yKp/60/

function thumbs(i,incr){
    var num_thumbs=2;
    if(i===null){
        i=$("#thumbs").prop('data-index'),
        i+=num_thumbs*incr;
    }
    i=Math.max(1,Math.min(i,$('#thumbs .UiUx3DSSVFlow').length-num_thumbs+1));
    $("#thumbs").prop('data-index',i);
    $('#thumbs .UiUx3DSSVFlow').hide();
    $('#thumbs .UiUx3DSSVFlow:nth-child(n+'+i+'):nth-child(-n+'+Number(i+num_thumbs-1)+')').show();
}
$("#panel .UiUx3DSSVFlow").not(':first').hide();
$("#thumbs .UiUx3DSSVFlow").click(function(){
    getIndex = $(this).index();
    $("#thumbs .clicked").removeClass('clicked');
    $("#panel .UiUx3DSSVFlow").hide().eq(getIndex).show();  
    $(this).addClass('clicked');
    thumbs(getIndex+1);        
});
$("#thumbs .UiUx3DSSVFlow:first").click();
$("#thumbs").prop('data-index',1);
$([['next',1],['prev',-1]]).each(function(){
    var that=this;
    $('#t'+that[0]).click(function(){
        thumbs(null,that[1]);
    });
    $('#l'+that[0]).click(function(){
        $('#thumbs .clicked')[that[0]]().click();
    });
});
$('#tprev').click();