左矢印と右矢印を使用して各 div をスクロールするスクローラーがあります。私が必要としているのは、スライドが最後に達したときに「次へ」または「前へ」ボタンを押すことで、スライドの最初にループバックできるようにするある種のJavaScriptまたはjqueryです。これまでの私のコードは次のとおりです。ある種のループ コードがあることは知っていますが、それを機能させるために実装する方法がわかりません。jQuery 以外に、ファイル内に追加されたスクローラー/カルーセル js コードは一切使用しません。
コードはこちら: http://jsfiddle.net/aj3ub/
JS
//this is used to call open the ID that contains where the scrolling starts
function overviper() {
el = document.getElementById("overviper");
el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
}
// these are used to click through left and right within the scroller
$(function () { // DOM READY shorthand
$("#rightbox, #leftbox").click(function () {
var dir = this.id == "rightbox" ? '+=' : '-=';
$(".all").stop().animate({ scrollLeft: dir + '990' }, 1000);
});
});
$(function () { // DOM READY shorthand
$("#rightbox1, #leftbox1").click(function () {
var dir = this.id == "rightbox1" ? '+=' : '-=';
$(".all").stop().animate({ scrollLeft: dir + '985' }, 1000);
});
});
$(function () { // DOM READY shorthand
$("#rightbox2, #leftbox2").click(function () {
var dir = this.id == "rightbox2" ? '+=' : '-=';
$(".all").stop().animate({ scrollLeft: dir + '985' }, 1000);
});
});
$(function () { // DOM READY shorthand
$("#rightbox3, #leftbox3").click(function () {
var dir = this.id == "rightbox3" ? '+=' : '-=';
$(".all").stop().animate({ scrollLeft: dir + '985' }, 1000);
});
});
$(function () { // DOM READY shorthand
$("#rightbox4, #leftbox4").click(function () {
var dir = this.id == "rightbox4" ? '+=' : '-=';
$(".all").stop().animate({ scrollLeft: dir + '985' }, 1000);
});
});
$(function () { // DOM READY shorthand
$("#rightbox5, #leftbox5").click(function () {
var dir = this.id == "rightbox5" ? '+=' : '-=';
$(".all").stop().animate({ scrollLeft: dir + '985' }, 1000);
});
});
$(function () { // DOM READY shorthand
$("#rightbox6, #leftbox6").click(function () {
var dir = this.id == "rightbox6" ? '+=' : '-=';
$(".all").stop().animate({ scrollLeft: dir + '985' }, 1000);
});
});