<script language="javascript">
var currentProgress = 0;
var time;
function begin(){
if (currentProgress == 100) {
currentProgress = 0;
}
if (time){
clearTimeout(time);
}
time = window.setTimeout("draw()", 100);
}
function draw() {
currentProgress = currentProgress + 10;
if (currentProgress > 100){
currentProgress = 100;
}
document.getElementById("inner1").style.width = currentProgress + "%";
document.getElementById("inner1").style.visibility = "visible";
document.getElementById("testProgressText").innerText = (currentProgress + '%');
if (currentProgress == 100)
{
return;
}
window.setTimeout("draw()", 100);
}
</script>
<body>
<div id="testProgress" style="float:left;width:100px;height:12px;border:2px solid;">
<span id="inner1" style="width:0%;line-height:12px;visibility:hidden;background-color:green;height: 12px;">
</span>
</div>
<div id="testProgressText" style="width:50px;height:12px;float:left;">
</div>
<button οnclick="begin()">Test Here</button>
</body>
js进度条
最新推荐文章于 2021-06-01 00:10:07 发布