Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/463.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript setInterval计时器需要动画进度条上的偏移量_Javascript_Jquery - Fatal编程技术网

Javascript setInterval计时器需要动画进度条上的偏移量

Javascript setInterval计时器需要动画进度条上的偏移量,javascript,jquery,Javascript,Jquery,我有一个剧本: jQuery(文档).ready(函数(){ 计时器(10) }); //计时器 var全局定时器; 函数计时器(intCount){ 全局计时器=设置间隔(函数(){ var intTickLength=10; 如果(整数小于10){ jQuery('#timer').html('00:0'+intCount--); jQuery('#bar').css('width',intCount*intTickLength+'px'); }否则{ jQuery('#timer').h

我有一个剧本:

jQuery(文档).ready(函数(){
计时器(10)
});
//计时器
var全局定时器;
函数计时器(intCount){
全局计时器=设置间隔(函数(){
var intTickLength=10;
如果(整数小于10){
jQuery('#timer').html('00:0'+intCount--);
jQuery('#bar').css('width',intCount*intTickLength+'px');
}否则{
jQuery('#timer').html('00:'+intCount--);
jQuery('#bar').css('width',intCount*intTickLength+'px');
}
如果(整数小于0){
停止计时器();
}
}, 1000);
}
函数stopTimer(){
clearInterval(全局计时器);
}​
我正在根据
intCount
*
intTickLength
(也许有更好的方法?)


问题是,当计数器达到1时,条形图上的最后一个勾号消失。我需要它一直保持到计数器达到0。我需要某种补偿。。有什么想法吗?我不是js专家,但我渴望成为js专家。

在减少计数器之前设置条大小:

jQuery('#bar').css('width', intCount * intTickLength + 'px');
jQuery('#timer').html('00:0' + intCount--);

在减少计数器之前设置条形尺寸:

jQuery('#bar').css('width', intCount * intTickLength + 'px');
jQuery('#timer').html('00:0' + intCount--);