Created
October 1, 2021 08:22
-
-
Save ruyut/684696d1fe6d197fb8b23459fda034cb to your computer and use it in GitHub Desktop.
HTML 簡易 自動前進 進度條
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<label>wait:</label> | |
<progress id="progress" max="100" value="0"></progress> | |
<button id="button" onclick="loadProgress()">Load</button> | |
<script type="text/javascript"> | |
function loadProgress() { | |
const progress = document.getElementById('progress'); | |
const button = document.getElementById('button'); | |
progress.value = 0; | |
const interval = setInterval(() => { | |
progress.value += 1; | |
button.disabled = true; | |
if (progress.value >= 100) { | |
clearInterval(interval); | |
button.disabled = false; | |
} | |
}, 10);//單位: 毫秒 | |
} | |
</script> | |
<!--Ruyut--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment