一个很好用的js倒计时!网页实时倒计时,精确到秒级,和天数倒计时原理一样。js倒计时一般用于商城网站团购,特卖,很多地方都可用到!希望能够给大家带来帮助! 效果如下: 复制代码 代码如下: <BR>.leave_time_font{margin-left:35%;} <BR>#fo{margin-left:32%;} <BR> WoYaoNi.CN-倒计时 WoYaoNi.CN <BR>$(document).ready(function(e) { <BR>var _countSeconds = 0; <BR>function _countDown(){ <BR>_countSeconds ++; <BR>$('input.surplustime').each(function(index, element) { <BR>var $this = $(this); <BR>var _totalTime = Number($this.val()) - _countSeconds; <BR>var _day = parseInt(_totalTime/86400); <BR>var _hours = parseInt(_totalTime%86400/3600); <BR>var _minutes = parseInt(_totalTime%86400%3600/60); <BR>var _seconds = parseInt(_totalTime%86400%3600%60); <BR>var _strLite = '<span class="day">'+_day+'天<span class="hour">'+_hours+'小时<span class="minutes">'+_minutes+'分<span class="seconds">'+_seconds+'秒'; <BR>var _str = '倒计时:'+_strLite; <BR>if($this.next('p.daojishi').length > 0){ <BR>$this.next('p.daojishi').html(_str); <BR>}else if($this.next('p.leave_time_font').length > 0){ <BR>$this.next('p.leave_time_font').html(_strLite); <BR>} <BR>}); <BR>} <BR>setInterval(_countDown, 1000); <BR>}) <BR> ini_set('date.timezone','Asia/Shanghai'); $currenttime = time(); $a = strtotime('2014-2-14 00:00'); $b = $a-$currenttime; ?> 小伙伴们距离情人节只剩: 0天0小时0分0秒