我引用的变量不断重置为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