HTML倒计时JS
2015-10-26 15:32
567 查看
var intDiff = parseInt($("#examTime").val());//倒计时总秒数
timer(intDiff);
function timer(intDiff){
window.setInterval(function(){
var day=0,
hour=0,
minute=0,
second=0;//时间默认值
if(intDiff > 0){
day = Math.floor(intDiff / (60 * 60 * 24));
hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
}
if (minute <= 9) minute = '0' + minute;
if (second <= 9) second = '0' + second;
//$('#day_show').html(day+"天");
//$('#hour_show').html('<s id="h"></s>'+hour+'时');
$('#minute_show').html('<s></s>'+minute+'分');
$('#second_show').html('<s></s>'+second+'秒');
intDiff--;
if(intDiff==0 || intDiff<0) examEnd();
}, 1000);
}
timer(intDiff);
function timer(intDiff){
window.setInterval(function(){
var day=0,
hour=0,
minute=0,
second=0;//时间默认值
if(intDiff > 0){
day = Math.floor(intDiff / (60 * 60 * 24));
hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
}
if (minute <= 9) minute = '0' + minute;
if (second <= 9) second = '0' + second;
//$('#day_show').html(day+"天");
//$('#hour_show').html('<s id="h"></s>'+hour+'时');
$('#minute_show').html('<s></s>'+minute+'分');
$('#second_show').html('<s></s>'+second+'秒');
intDiff--;
if(intDiff==0 || intDiff<0) examEnd();
}, 1000);
}
相关文章推荐
- js this关键字
- 去掉jsp编译后的空格
- js基本应用
- jsp获取后台返回的对象中包含的list以及el获取后台json对象并且解析
- ajax 和jsonp 不是一码事 细读详解
- 常用排序算法的JS实现
- MFC JSON解析-开源jsoncpp
- html模板与json数据交互
- Javascript use strict模式和对象
- js中的this关键字详解
- 在JSP中动态生成随机验证码,登录时后台校验验证码,以及如何避免同一个验证码被重复提交爆破密码
- JS调试加断点
- WebGL With Three.js – Lesson 6(转)
- js的运用
- jsf2.0视频
- NSData,NSImage,NSDictionary,NSString,NSURL 等等互相转换
- log4js日志文件库的使用
- JS当中获取Web访问基路径
- extjs官方实例收集
- JavaScript中的数据类型转换方法小结