html - Countdown Timer in Javascript -
this question exact duplicate of:
i have little countdown code written in javascript html document. need someone's knowledge , modify code can input own time , start countdown button.
counter_start = 3 function tick () { if (document.getelementbyid ('counter').firstchild.data > 0) { document.getelementbyid ('counter').firstchild.data = document.getelementbyid ('counter').firstchild.data - 1 settimeout ('tick()', 1000) } else { document.getelementbyid ('counter').firstchild.data = 'done' } } if (document.getelementbyid) onload = function () { var t = document.createtextnode (counter_start) var p = document.createelement ('p') p.appendchild (t) p.setattribute ('id', 'counter') var body = document.getelementsbytagname ('body')[0] var firstchild = body.getelementsbytagname ('*')[0] body.insertbefore (p, firstchild) tick() }
- remove
tick()
- update
counter_start
value want - call
tick
on click of button.
Comments
Post a Comment