计时器
2016-06-06 10:08
267 查看
function countDown(){
var timeBox = $('.countdown i');
var endTime = new Date(timeBox.data('time')),
starTime = new Date(),
ts = endTime.getTime()-starTime.getTime(),
d= 0,
h= 0,
m = 0,
s= 0;
if(ts>=0){
d=Math.floor(ts/1000/60/60/24);
h=Math.floor(ts/1000/60/60%24);
m=Math.floor(ts/1000/60%60);
s=Math.floor(ts/1000%60);
}
timeBox.html(h+"小时"+m+"分"+s+"秒");
setTimeout(countDown,1000);
}
var timeBox = $('.countdown i');
var endTime = new Date(timeBox.data('time')),
starTime = new Date(),
ts = endTime.getTime()-starTime.getTime(),
d= 0,
h= 0,
m = 0,
s= 0;
if(ts>=0){
d=Math.floor(ts/1000/60/60/24);
h=Math.floor(ts/1000/60/60%24);
m=Math.floor(ts/1000/60%60);
s=Math.floor(ts/1000%60);
}
timeBox.html(h+"小时"+m+"分"+s+"秒");
setTimeout(countDown,1000);
}
相关文章推荐
- Sublime Text 3运行JavaScript控制台
- javascript 红宝书笔记之操作日期
- VB.NET中网络编程所需组件WinHTTP的添加
- valueAsNumber将字符串转化成数字,number属性
- javascript构造函数中的公有,私有,特权和静态成员
- input type =text,按回车键自动提交
- 如何检查C++中的内存泄漏 vs自带
- UIView之drawRect:和Quartz 2D的坐标系问题
- TableView 点击项目后恢复原来状态
- Linux下面/usr/local和opt目录
- 解决SQL Server 2008 无法连接到(local)
- SSL握手过程
- C/C++ 内存泄漏检测工具 Visual Leak Detector
- 常用正则表达式大全 -- 正则表达式基本语法
- tomcat6下jsp出现getOutputStream() has already been called for this response异常的原因和解决方法
- user-select : 保护版权内容的简单方案
- 剑指offer(6)-旋转数组的最小数字
- 音乐播放器
- tomcat端口配置
- JavaFX Dialogs (官方支持)