javascript countdown clock

前端 未结 4 643
执念已碎
执念已碎 2021-01-03 19:05
 

        
4条回答
  •  感情败类
    2021-01-03 19:36

    The element in the script is the id of the tag you pass to the function.
    So countdown('div1') will show a timer in a tag with id="div1"

    However your particular timer does not allow multiple instances and uses a global var called interval.

    Generate the JSON on the server and the rest takes care of itself

    HERE is an OO version that is more precise since it is only calculating the end time instead of relying on interval which will block if the browser is busy: http://jsbin.com/ujuzo5/edit

    And here is my original solution with the help of the good folks at SO here: Broken closure - please help me fix it

    
    shoes: 
    trousers:

提交回复
热议问题