;(function($){
$.fn.extend({
CountDown: function(StartDate, EndDate) {
var Timmer = null,
$this = $(this),
start_time = StartDate.getTime(),end_time = EndDate.getTime(),
_tempTime,day,hour,min,sec,
$day = $this.find('.day'),$hour = $this.find('.hour'),$min = $this.find('.min'),$sec = $this.find('.sec');
if(start_time>end_time){throw new Error("#"+$this.attr('id')+'开始结束时间不正确!')}
playTime();
function playTime(){
if(Timmer){clearTimeout(Timmer)}
end_time-=1000;
if(end_time<start_time){$this.addClass('timeover');return false;}
_tempTime = end_time - start_time;
day = Math.floor(_tempTime/86400000);
_tempTime -= day*86400000;
hour = Math.floor(_tempTime/3600000);
_tempTime -= hour*3600000;
min = Math.floor(_tempTime/60000);
_tempTime -= min*60000;
sec = Math.floor(_tempTime/1000);
$day.text(day);
$hour.text(hour);
$min.text(min);
$sec.text(sec);
Timmer = setTimeout(playTime,1000);
}
return this;
}
});
})(jQuery);
$('#dome1').CountDown(new Date("2014/6/9 11:11:1"), new Date("2014/6/9 11:12:10"));
$('#dome2').CountDown(new Date("2014/6/9 11:11:1"), new Date("2014/6/10 11:11:10"));
$('#dome3').CountDown(new Date("2014/6/9 11:11:1"), new Date("2014/6/12 11:11:10"));
$('#dome4').CountDown(new Date("2014/6/9 11:11:1"), new Date("2014/6/14 11:11:10"));
$('#dome5').CountDown(new Date("2014/6/9 11:11:1"), new Date("2014/6/13 11:11:10"));
<div id="dome1">
<span class="day"></span>天|<span class="hour"></span>时|<span class="min"></span>分|<span class="sec"></span>秒
</div>
<div id="dome2">
<span class="day"></span>天|<span class="hour"></span>时|<span class="min"></span>分|<span class="sec"></span>秒
</div>
<div id="dome3">
<span class="day"></span>天|<span class="hour"></span>时|<span class="min"></span>分|<span class="sec"></span>秒
</div>
<div id="dome4">
<span class="day"></span>天|<span class="hour"></span>时|<span class="min"></span>分|<span class="sec"></span>秒
</div>
<div id="dome5">
<span class="day"></span>天|<span class="hour"></span>时|<span class="min"></span>分|<span class="sec"></span>秒
</div>