console
var down = 0
function start() {
if (down === 0) {
down = 1
var progress = 0
var timer = setInterval(function() {
progress ++
document.getElementById('progress').value = progress
if (progress >= 100) {
clearInterval(timer)
down = 0
}
}, 100)
} else {
alert('正在下载中')
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
</head>
<body>
<div id="container">
<progress id="progress" value="0" max="100"></progress>
<button onclick="start()">下载</button>
</div>
</body>
</html>
#container {
display: flex;
justify-content: center;
align-items: center;
}
button {
background-color: transparent;
border: 1px solid #DDDDDD;
margin: 10px;
}
botton:hover {
cursor: pointer;
}