Q:

Countdown with jQuery

So, I have this outputted from my DB: 
00:01:53
Inside a span tag
<span class="jb_timer">00:01:53</span>

So my question is, how can I make it countdown with jQuery?
Thanks.

A:

Here's something that should get you started in the right direction:
var remaining = $("span.jb_timer").text(),
    regex = /\d{2}/g,
    matches = remaining.match(regex),
    hours = matches[0],
    minutes = matches[1],
    seconds = matches[2],
    remainingDate = new Date();

remainingDate.setHours(hours);
remainingDate.setMinutes(minutes);
remainingDate.setSeconds(seconds);

var intvl = setInterval(function () {
    var totalMs = remainingDate.getTime(),
        hours, minutes, seconds;

    remainingDate.setTime(totalMs - 1000);

    hours = remainingDate.getHours();
    minutes = remainingDate.getMinutes();
    seconds = remainingDate.getSeconds();

    if (hours === 0 && minutes === 0 && seconds === 0) {
        clearInterval(intvl);
    }

    $("span.jb_timer").text(
        (hours >= 10 ? hours : "0" + hours) + ":" +
        (minutes >= 10 ? minutes : "0" + minutes)  + ":" +
        (seconds >= 10 ? seconds : "0" + seconds));

}, 1000);

Working Example: http://jsfiddle.net/andrewwhitaker/YbLj4/
Notes:

First you have to parse the initial hours, minutes, and seconds out of the span's text. Do this using a simple regular expression.
Use setInterval to set up a timer that runs every 1000 milliseconds.
When that timer fires, subtract 1000 ms from the time and update the span's text appropriately.
When the hours, minutes, and seconds reach 0, clear (cancel) the interval.

