<script type="text/javascript"> var intDiff = parseInt(15); //倒计时总秒数量 function timer(intDiff) { index = 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 (day == 0 && hour == 0 && minute == 0 && second == 0) { clearInterval(index); } }, 1000); } $(function () { timer(intDiff); }); </script> html <h1>网页上的倒计时</h1> <div class="time-item"> <span id="day_show">0天</span> <strong id="hour_show">0时</strong> <strong id="minute_show">0分</strong> <strong id="second_show">0秒</strong> </div> css <style> h1 { font-family:"微软雅黑"; font-size:40px; margin:20px 0; border-bottom:solid 1px #ccc; padding-bottom:20px; letter-spacing:2px; } .time-item strong { background:#C71C60; color:#fff; line-height:49px; font-size:36px; font-family:Arial; padding:0 10px; margin-right:10px; border-radius:5px; box-shadow:1px 1px 3px rgba(0,0,0,0.2); } #day_show { float:left; line-height:49px; color:#c71c60; font-size:32px; margin:0 10px; font-family:Arial,Helvetica,sans-serif; } .item-title .unit { background:none; line-height:49px; font-size:24px; padding:0 10px; float:left; } </style> |
小巧实用js倒计时
时间: 2024-10-04 22:09:32
小巧实用js倒计时的相关文章
js倒计时关闭当前页面代码
js倒计时关闭当前页面代码:很多网站在关闭网页之前会给出一个倒计时效果,这样可以让浏览者做到根据相应的情况进行操作,比较人性化,下面就通过实例代码介绍一下如何实现此效果.代码实例如下: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name=&quo
实用js+css多级树形展开效果导航菜单
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Typ
js倒计时函数和(js禁用和恢复a标签的操作)
<script type="text/javascript"> /*获取手机号*/ var start_time=60; function get_phone_nums(){ var get_cus_phone=$('.get_cus_phone').val();//得到消费者填写的的手机号 var reg = new RegExp("^13[0-9]{9}$|14[0-9]{9}|15[0-9]{9}$|18[0-9]{9}|17[0-9]{9}$")
js 倒计时(可自定义时间)
原文 链接 http://www.cnblogs.com/liygheart/p/3605160.html <html> <head> <title>js 倒计时</title> </head> <body> <div> <h4>距离<input type="text" id="inputdate" value="2014-4-5"/> &
JS倒计时网页自动跳转代码
<title>JS倒计时网页自动跳转代码</title> <script language="JavaScript" type="text/javascript"> function delayURL(url) { var delay = document.getElementById("time").innerHTML; if(delay > 0) { delay--; document.getElem
Js倒计时程序
Js倒计时程序 点击下载
js倒计时功能
<input id="countdown" type="text" value="140时50分20秒"> <script> var oCountdown = document.getElementById("countdown"), nowStamps = Date.now() - 100, // 服务器当前时间 endStamps = Date.now() + 50000 - 100, // 活动结
Mac上小巧实用的GIF格式录屏软件 LICEcap
LICEcap 是一款小巧使用的Mac屏幕录制软件,它以GIF格式来录制屏幕内容,用户可以自定帧率和录制范围.这样就能控制生成文件的大小,非常便捷实用哦.点击进入下载 <ignore_js_op> 软件的界面是一个透明的窗口 <ignore_js_op> 点击“Record”后选择GIF文件的保存位置,然后进入3秒倒计时 <ignore_js_op> 很有意思哦,赶快试试吧! <ignore_js_op> http://www.macx.cn/thread-
JS倒计时,不会重复执行
直接上代码,亲自测试了的,没问题咯 <html> <head> <title>点击获取验证码按钮后按钮变灰,倒计时一段时间后又可重复点击</title> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.6.4/jquery.js"></script> </head> <body>