Skip to content

Instantly share code, notes, and snippets.

@fakefarm
Created August 31, 2013 17:50
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 fakefarm/6399670 to your computer and use it in GitHub Desktop.
Save fakefarm/6399670 to your computer and use it in GitHub Desktop.
How do I enter a number to count down, then watch it drop?
<!DOCTYPE html>
<html>
<head>
<title>Count Down</title>
<style type="text/css"> .styles {font: bold 24pt sans; padding: 10px; border: 2px solid black; border-radius: 2px; } </style>
</head>
<body>
<h1>Countdown</h1>
<span class="styles" id="countdown"></span> <!-- The time gets inserted here -->
<script>
// How do I enter a number to count down, then watch it drop?
function countdown(time){
var count = document.getElementById("countdown");
while(time > 0){
count.innerHTML = time;
time = time - 10;
setTimeout(1000);
}
}
window.onload = countdown(10000);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment