您好,欢迎来到优茬娱乐网。
搜索
您的当前位置:首页js网页实时倒计时精确到秒级_javascript技巧

js网页实时倒计时精确到秒级_javascript技巧

来源:优茬娱乐网


一个很好用的js倒计时!网页实时倒计时,精确到秒级,和天数倒计时原理一样。js倒计时一般用于商城网站团购,特卖,很多地方都可用到!希望能够给大家带来帮助!

效果如下:

代码如下:





WoYaoNi.CN-倒计时


WoYaoNi.CN




$(document).ready(function(e) {
var _countSeconds = 0;
function _countDown(){
_countSeconds ++;
$('input.surplustime').each(function(index, element) {
var $this = $(this);
var _totalTime = Number($this.val()) - _countSeconds;
var _day = parseInt(_totalTime/800);
var _hours = parseInt(_totalTime%800/3600);
var _minutes = parseInt(_totalTime%800%3600/60);
var _seconds = parseInt(_totalTime%800%3600%60);
var _strLite = ''+_day+'天'+_hours+'小时'+_minutes+'分'+_seconds+'秒';
var _str = '倒计时:'+_strLite;
if($this.next('p.daojishi').length > 0){
$this.next('p.daojishi').html(_str);
}else if($this.next('p.leave_time_font').length > 0){
$this.next('p.leave_time_font').html(_strLite);
}
});
}
setInterval(_countDown, 1000);
})



ini_set('date.timezone','Asia/Shanghai');
$currenttime = time();
$a = strtotime('2014-2-14 00:00');
$b = $a-$currenttime;
?>


小伙伴们距离情人节只剩:

0天0小时0分0秒





Copyright © 2019- ucpa.cn 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务