您的位置:首页 > 其它

简单的进度条

2016-02-24 13:30 309 查看
<div class="progressBar">
<div id="bar"></div>
</div>

css样式

.progressBar{
width: 200px;
height: 8px;
border: 1px solid #98AFB7;
border-radius: 5px;
margin-top: 10px;
}
#bar{
width: 0px;
height: 8px;
border-radius: 5px;
background: #5EC4EA;
}
js代码

progressBar()

function progressBar (){
//初始化js进度条

$("#bar").css("width","0px");

//进度条的速度,越小越快
var speed = 20;

bar = setInterval(function(){
nowWidth = parseInt($("#bar").width());
if(nowWidth <= 200){
barWidth = (nowWidth + 1)+"px";
$("#bar").css("width" , barWidth);
}else{
//进度条读满之后,停止
clearInterval(bar);
}
},speed)

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: