jquery简单倒计时实现方法
作者:bea
本文实例讲述了jquery简单倒计时实现方法。分享给大家供大家参考,具体如下: var intDiff = parseInt(60); //倒计时总秒数量function timer(intDiff) { window.setInterval(function () { var day = 0, hour = 0, minute = 0, second = 0; //时间默认值 if (intDiff > 0) {
本文实例讲述了jquery简单倒计时实现方法。分享给大家供大家参考,具体如下:
var intDiff = parseInt(60); //倒计时总秒数量
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--;
}, 1000);
}
$(function () {
timer(intDiff);
});
希望本文所述对大家jQuery程序设计有所帮助。
有用 | 无用
var intDiff = parseInt(60); //倒计时总秒数量
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--;
}, 1000);
}
$(function () {
timer(intDiff);
});
希望本文所述对大家jQuery程序设计有所帮助。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- js实现n秒倒计时后才可以点击的效果
- 图解js图片轮播效果
- 谈谈我对JavaScript原型和闭包系列理解(随手笔记6)
- 基于jquery实现页面滚动到底自动加载数据的功能
- js点击按钮实现带遮罩层的弹出视频效果
- js获取本机操作系统类型的两种方法
- javascript精确统计网站访问量实例代码
- js实现图片轮播效果
- js实现图片上传并正常显示
- thinkphp实现无限分类(使用递归)
- 15个常用的jquery代码片段
- js实现滚动条滚动到页面底部继续加载
- jQuery对html元素的取值与赋值实例详解
- jQuery中trigger()与bind()用法分析
- jQuery+JSON实现AJAX二级联动实例分析
- js获取url传值的方法
- JavaScript setTimeout使用闭包功能实现定时打印数值
- jquery获取css的color值返回RGB的方法
- jQuery实现textarea自动增长宽高的方法