Skip to content Skip to sidebar Skip to footer

Jquery Make Kellishaver Stopwatch Plugin Countdown Instead Of Up

I need a stopwatch/timer to countdown. I'm trying to use Kellis Havers stopwatch jQuery plugin and change it to countdown. But can't figure out how to make it substract instead of

Solution 1:

parseInt will work fine if you include 10 as a second argument.

Change to:

        hour = parseInt(h.text(),10);
        minute = parseInt(m.text(),10);
        second = parseInt(s.text(),10);

        second--;

        if(second < 0) {
            second = 59;
            minute = minute - 1;
        }

        if(minute < 0) {
            minute = 59;
            hour = hour - 1;
        }

        h.html("0".substring(hour >= 10) + hour);
        m.html("0".substring(minute >= 10) + minute);
        s.html("0".substring(second >= 10) + second);

jsFiddle

Post a Comment for "Jquery Make Kellishaver Stopwatch Plugin Countdown Instead Of Up"