Skip to content

Instantly share code, notes, and snippets.

@ruyut
Created October 1, 2021 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruyut/684696d1fe6d197fb8b23459fda034cb to your computer and use it in GitHub Desktop.
Save ruyut/684696d1fe6d197fb8b23459fda034cb to your computer and use it in GitHub Desktop.
HTML 簡易 自動前進 進度條
<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