作者oao54bb (央)
看板Ajax
标题[问题] 变数初始化问题
时间Mon Apr 2 21:52:27 2012
这是我的程式码:
var NN = 0; // 显示笔数
var GOGO = 0; //移动座标位置
var times = 1; //切换笔数
$(".near ul").css({left:0});
$('.next').click(function(){
if(times<datas.length/10){ // 每次仅显示10笔,直到没有资料
NN+=10;
times+=1;
GOGO = NN*58*-1;
$(".near ul").stop().animate({left:GOGO},500);
}
});
$('.prev').click(function(){
if(NN>0){
NN-=10;
times-=1;
GOGO = NN*58*-1;
$(".near ul").stop().animate({left:GOGO},500);
}
});
这是一个左右转动的照片轮播程式。
流程:
---------------------------------------------
┌┐ ┌┐ ┌┐ ┌┐ ┌┐ ┌┐ ┌┐
< └┘ └┘ └┘ └┘ └┘ └┘ └┘ >
---------------------------------------------
问题:
如何在下一次读取 data前,
先将↓ 的NN、times,GOGO,animate({left:GOGO},500)
都先回归到最原始的数值 0 ?
※在没有重新整理的情况下
$('.next').click(function(){
if(times<datas.length/10){ // 每次仅显示10笔,直到没有资料
NN+=10;
times+=1;
GOGO = NN*58*-1;
$(".near ul").stop().animate({left:GOGO},500);
}
});
--
Blog
http://oao54bb.blogspot.com/
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 123.240.34.196