我想通過使用jQuery的「前進」和「後退」按鈕在函數數組內正確「導航」。我無法正確導航後退按鈕。使用jQuery導航一個函數數組
var functions = [ function0, function1, function2, function3, function4, function5 ];
var index = 0;
$("#forward").click(function() {
functions[Math.abs(index % functions.length)]();
index++;
});
$("#back").click(function() {
functions[Math.abs(index % functions.length)]();
index--;
});
下面是完整的代碼:
https://jsfiddle.net/sa13yrtf/2/