Jquery - custom countdown
- by matthewsteiner
So I found this countdown at http://davidwalsh.name/jquery-countdown-plugin, I altered it a little bit:
jQuery.fn.countDown = function(settings,to) {
settings = jQuery.extend({
duration: 1000,
startNumber: $(this).text(),
endNumber: 0,
callBack: function() { }
}, settings);
return this.each(function() {
//where do we start?
if(!to && to != settings.endNumber) { to = settings.startNumber; }
//set the countdown to the starting number
$(this).text(to);
//loopage
$(this).animate({
'fontSize': settings.endFontSize
},settings.duration,'',function() {
if(to > settings.endNumber + 1) {
$(this).text(to - 1).countDown(settings,to - 1);
}
else
{
settings.callBack(this);
}
});
});
};
Then I have this code:
$(document).ready(function(){
$('.countdown').countDown({
callBack: function(me){
$(me).text('THIS IS THE TEXT');
}
});
});
I don't mind taking everything out of the "animate" loop; I'd prefer that since nothing needs to be animated. (I don't need the font size to change).
So everything's working to a point. I have a span with class countdown and whatever is in it when the page is refreshed goes down second by second. However, I need it to be formatted in M:S format.
So, my two questions:
1) What can I use instead of animate to take care of the loop yet maintain the callback
2) How (where in the code should I) can I play with the time format?
Thanks.