我的畫廊有縮略圖,它們都具有相同的名稱相同的較大圖像,我使用php動態鏈接每個大拇指。然後,我使用jQuery使用href屬性顯示更大的圖像,以獲取大圖像的路徑。當燈箱彈出後,點擊下一個應該允許我瀏覽和查看每個圖像,而只有下一個圖像被點擊後纔會進入下一個圖像,但如果下一個圖像被再次點擊,它會顯示相同的圖像。自定義燈箱,下一個按鈕不會多於一次工作
我附上圖片給出一個基本的想法,因爲我不擅長解釋。
動態加載縮略圖在我的畫廊:
畫廊中的最後一個拇指被點擊時,這個彈出(建築物圖片):
在下次點擊該照片(泡沫破裂)的diplayed,但是在下次點擊幾次,照片(泡沫破裂)仍然是:
我的代碼:
var Picture = $('.lightbox'); // path to full sized picture the class lightbox identifies a link <a>
var pic = Picture.index(this) //finds index
var num = Picture.length;//finds the total amount of thumbnails
$('#next').click(function(e){ //when next is click prevent default
e.preventDefault();
if(pic<(num-1)){
var ntx = (pic)+1;
}
if(pic == (num-1)){
ntx= 0;
}
var nxt = Picture[ntx];
var img = $('.box img');
img.remove();
$('.box').hide(); // removes the current image
$('.box').append('<img align="center" id="motown" src="'+nxt+'" style=" z-index:52px;" > '); //appends the next image and sets the div container to hidden and hide the new image
});
我可以在我的代碼中添加什麼,以便每次都能使下一個按鈕有效?
什麼是'num'變量的回報? –
@ZeeTee它返回縮略圖的總量。 – user1381778
它可能是最好的設置在一個jsfiddle:http://jsfiddle.net –