FivePage = {};
FivePage.show = function() {
this.change11 = null;
this.length = 0;
}
FivePage.show.prototype.Ypage1 = function(id) {
change11 = setInterval(function() {
length++;
if(length == $("#" + id + " li").length) {
length = 0;
}
console.log("第五页定时器");
console.log(this.length);
console.log(this.ll);
showaa(length);
}, 2000);
function showaa(length) {
$("#" + id + " li").eq(length - 1).fadeOut(1000); //将上一张图片隐藏
$("#" + id + " li").eq(length).fadeIn(1000); //将这张图片出现
}
}
var cbb = new FivePage.show();
btn1.onclick = function() {
test11.style.display = "block";
test12.style.display = "none";
clearInterval(change11);
alert("现在的下标是:"+length+"page1");
cbb.Ypage1("test11");
}
btn2.onclick = function() {
test12.style.display = "block";
test11.style.display = "none";
clearInterval(change11);
alert("现在的下标是:"+length+"Page2");
cbb.Ypage1('test12');
};
各位大哥,我现在的问题是,我点击btn2的时候,他的length不会从0开始,我需求是
点击bun1length从0开始走,这个时候,btn1的length走到了3,我在点击btn2的时候,length从0开始走。(这个时候,length会等于3,而不是0),所以问题是他们公用了一个length,我写两个变量,会报错为 not defined
当我再次点击btn1的时候,length会从之前的3继续开始走