JavaScript实现简单动态进度条效果

本文实例为大家分享了js实现动态进度条效果的具体代码,供大家参考,具体内容如下

1.效果

2.源码

<html>

<head>

<script type="text/javascript">

window.onload = function () {

var myProgress = document.getElementById("myProgress");

var mySpan = document.getElementById("mySpan");

var value = myProgress.value;

mySpan.innerText = value + "%";

var ID = setInterval(function () {

value = myProgress.value;

if (value < 100) {

value += 10;

myProgress.value = value;

mySpan.innerText = value + "%";

}

if (value == 100) {

clearInterval(ID);

}

}, 500);

}

</script>

</head>

<body>

<label for="myProgress">进度条</label>

<progress id="myProgress" value="0" max="100"></progress>

<span id="mySpan"></span>

</body>

</html>

以上是 JavaScript实现简单动态进度条效果 的全部内容, 来源链接: utcz.com/z/346499.html

回到顶部