The received parameter end is a must pass, the format is a/delimited date string, start is optional, does not pass the countdown from now on, callback is also optional, to the countdown to execute the custom function.
Countdown ({ ' end ': ' 2015/9/1 17:12:00 ', ' callback ':function () { document.getElementById (' countdown '). InnerHTML = ' The end! ' ; } });
(function (){ functionCountdown (config) {varStartDate = Config.start?NewDate (Config.start):NewDate (); varEndDate =NewDate (config.end); varid = config.id | | ' Countdown '; varTime = (enddate-startdate)/1000;if(Time < 0){ if(config.callback) {config.callback (); } return; } varDay = parseint (time/86400, 10);varhour = parseint (TIME%86400/60/60, 10); varminute = parseint (TIME%86400%3600/60, 10);varSecond = parseint (time%86400%3600%60, 10); SetTimeout (function() {document.getElementById (id). InnerHTML= day+ ' Day ' +hour+ ': ' +minute+ ': ' +second; Countdown (config); }, 1000); } Window.countdown=Countdown;}) ();
A simple Countdown JS plugin