js setInterval在谷歌浏览器控制台能看到在运行 但是前台体现不出来
点完trybtn后,前台页面里的进度条和值都正常累加 但是走4次之后,后台可以看到setInterval一直在运行 这里我用的是thecount 一直累加可以看到。但是前台页面上的值就不动了。在网上差很长时间也没找到,求大神指教啊。
$("#trybtn").click(function () {
var thecount=0;
var inCount=$(".incount").size();
var steptime=1000*3;
var myVar=setInterval(function(){
for(var i=0;i<inCount;i++){
//获取进度条宽度百分比
var a=0,b=0,c=0,d=0,e=0,newValue=0;
a=parseInt($(".progress-bar"+i).css("width"));
b=parseInt($(".progress"+i).css("width"));
c= parseInt(a/b*100);
//获取每次步进值
var allowtime=parseInt($(".theTime"+i).text());
var stepValue=parseInt(100/(allowtime*60*1000/steptime));
newValue=c+stepValue+1;
console.log(newValue);
if(newValue>60&&newValue<100){
$(".progress-bar" + i).attr("class", "progress-bar progress-bar"+i+" progress-bar-warning");
}
if(newValue>30&&newValue<60){
$(".progress-bar" + i).attr("class", "progress-bar progress-bar"+i+" progress-bar-success");
}
if(newValue>=100) {//完成标记
$(".progress-bar" + i).css("width", "100%");
$(".theTag" + i).text("100%");
$(".progress-bar" + i).attr("class", "progress-bar progress-bar"+i+" progress-bar-danger");
$(".trData"+i).fadeOut(3000);
$(".trData"+i).css('background-color','red');
}
else{
$(".progress-bar" + i).css("width", newValue+"%");
$(".theTag" + i).text(newValue+"%");
}
}
thecount++;
console.log("执行了:"+thecount);
console.log("----------------------------------");
},steptime);
});