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() } 

jsfiddle

  1. remove tick()
  2. update counter_start value want
  3. call tick on click of button.

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -