Skip to content

Instantly share code, notes, and snippets.

@yehchge
Created July 21, 2023 07:46
Show Gist options
  • Save yehchge/0081d467b10429196516f9f74bb94e32 to your computer and use it in GitHub Desktop.
Save yehchge/0081d467b10429196516f9f74bb94e32 to your computer and use it in GitHub Desktop.
動態在網頁上顯示數字
<!DOCTYPE html>
<html>
<head>
<title>Dynamic Number Display</title>
</head>
<body>
<div id="numberDisplay"></div>
<script>
var count = 1;
function displayNumber() {
document.getElementById("numberDisplay").innerHTML = count;
count++;
if (count > 10) {
clearInterval(interval);
}
}
var interval = setInterval(displayNumber, 1000); // 每秒更新一次
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment