合計 10 枚の 5 枚の画像が 2 行で構成された画像ギャラリーがあります。私は20枚の画像を持ち、ユーザーが次のボタンを押すとギャラリーが次の10枚の画像に移動する前に、ユーザーが前の10枚の画像に移動しようとしています。私の人生では、前と次のボタンが機能しない理由がわかりません。
jQuery:
var $item = $('div.folder'), //Cache your DOM selector
visible = 5, //Set the number of items that will be visible
index = 0, //Starting index
endIndex = ($item.length / visible) - 1; //End index
$('div#arrowR-spring').click(function () {
if (index < endIndex) {
index++;
$item.animate({
'left': '-=315px'
});
} else {
index = 0;
$item.animate({
'left': '+=' + (315 * endIndex) + 'px'
});
}
});
$('div#arrowL-spring').click(function () {
if (index > 0) {
index--;
$item.animate({
'left': '+=315px'
});
} else {
index = endIndex;
$item.animate({
'left': '-=' + (315 * endIndex) + 'px'
});
}
});
これが私が現在持っているものです: link to my fiddle . どんな助けでも大歓迎です!