Hello everyone. I have this countdown script that I got from phpnovice…thanks phpnovice. I’ve been using it for a while but for some reason I never really looked at it to see how it works. Can someone simply take me through the code to explain how it works and what makes it work, just in case I would want to make something similar in the future.
[code]var count = 300
function countdown() {
if(count >= 0){
var obj = document.getElementById(“countdown”);
obj.replaceChild(document.createTextNode(count.toMinutesAndSeconds()), obj.firstChild);
count–;
window.setTimeout(“countdown()”,1000);
}
}
Number.prototype.toMinutesAndSeconds = function() {
var nn, curTime = new Date(this * 1000);
return nn=curTime.getMinutes() + “:” +
(((nn=curTime.getSeconds())<10)?”0″+nn:nn);
}
Thanks in advance.
lonogod