Created
August 31, 2013 17:50
-
-
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?
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
<!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