Created
January 29, 2013 20:00
-
-
Save Beneboe/4667222 to your computer and use it in GitHub Desktop.
Flexible countdown that can find out the countdown time automatically
This file contains hidden or 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
function countdowntimer(element, secs) { | |
var i = (secs) ? secs : element.innerHTML; | |
var t1 = setInterval(function() { | |
if(i != 0){ | |
i--; | |
} | |
else{ | |
clearInterval(t1); | |
//timer ends here | |
} | |
element.innerHTML = i; | |
}, 1000); | |
} | |
countdowntimer(document.querySelector("span")); |
This file contains hidden or 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
<span>span</span> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment