Jquery 定时器 联合 bootStarp 进度条

DIv样式

<div id= "inner_stop" class="progress progress-striped active" style= "width: 50%;margin: auto;">
<div id="inner" class="progress-bar progress-bar-success" ></div>
</div>

 

function show() {
var inner_stop_width = document.getElementById("inner_stop").offsetWidth;
if (document.getElementById("inner").offsetWidth < inner_stop_width)//offsetWidth实现的时候width是没有宽度的,而style.width实现的时候则有宽度(px)!
{
document.getElementById("inner").style.width = (document
.getElementById("inner").offsetWidth + 20)
+ "px";//每次执行show()函数的时候宽度都会加上20!
console.log(document.getElementById("inner").style.width);//console 控制台 :可以在网页上看到width的变化(利用F12)
} else {
document.getElementById("inner").style.width = inner_stop_width
+ "px";//如果大于1000px的话,只能将1000px赋值给border-width;!
stop();//此时就应该执行停止定时器的函数!
}
}
var timer;//定义在两个函数外面,因为两个函数都会用到!
function start() {
timer = window.setInterval(show, 2000);//每隔200ms调用一次show函数
}
function stop() {
timer = window.clearInterval(timer);
$.bootstrapLoading.end();
}

转载于:https://www.cnblogs.com/DeBugger-/p/10254841.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值