我引用的變量不斷重置爲0,爲什麼?每個部分都有一組Previous和Next按鈕,最初它們工作正常,但當我返回到某個部分時,該部分的計數器設置爲0.它應該保留之前設置的數字。提前致謝。這不是正在使用的實際代碼,但它證明了問題(我希望)jquery使用參考變量
var currentPageIndex = null;
var section1_count = 0;
var section2_count = 0;
var section3_count = 0;
function checkSectionPage(value){
switch(value){
case "section1":
currentPageIndex= section1_count;
break;
case "section2":
currentPageIndex= section2_count;
break;
case "section3":
currentPageIndex= section3_count;
break;
}
}
$('.slidePrevious').click(function(){
checkSectionPage($(this).parent().attr('id'));
currentPageIndex--;
});
$('.slideNext').click(function(){
checkSectionPage($(this).parent().attr('id'));
currentPageIndex++;
});
,因爲你永遠不會更新節數。它總是零。 – epascarello