How can I create an Countdown Timer that when it reaches 0 goes up again with javascript

177 views Asked by At

I know nothing about javascripting, I am an internship trying to make a countdown timer. When it reaches 0 it would go up again until someone presses space bar to stop and start, if it is even possible of course. Can you help me out? I know it sounds like do it for me job but please help me.

1

There are 1 answers

2
Grigory Kornilov On
    var time = 60;

window.setInterval(test, 1000);

function test()
{
    //update time
    time -=1;
    //update the div to show the time
    $('#testDiv').html(time); 

    //hide the div if the time is 0
    if(time == 0)        
    {
        $('#testDiv').remove();
    }
}