jquery时间倒计时案例
来源:互联网 发布:物理数据库模型 编辑:程序博客网 时间:2024/06/08 02:28
<script> //定义参数可返回当天的日期和时间 var startTime = new Date(); //调用设置年份 startTime.setFullYear(2017, 10, 27); //调用设置指定的时间的小时字段 startTime.setHours(23); //调用设置指定时间的分钟字段 startTime.setMinutes(59); //调用设置指定时间的秒钟字段 startTime.setSeconds(59); //调用置指定时间的毫秒字段 startTime.setMilliseconds(999); //定义参数可返回距 1970 年 1 月 1 日之间的毫秒数 var EndTime=startTime.getTime(); //定义方法 function GetRTime(){ //定义参数可返回当天的日期和时间 var NowTime = new Date(); //定义参数 EndTime减去NowTime参数获得返回距 1970 年 1 月 1 日之间的毫秒数 var nMS = EndTime - NowTime.getTime(); //定义参数 获得天数 var nD = Math.floor(nMS/(1000 * 60 * 60 * 24)); //定义参数 获得小时 var nH = Math.floor(nMS/(1000*60*60)) % 24; //定义参数 获得分钟 var nM = Math.floor(nMS/(1000*60)) % 60; //定义参数 获得秒钟 var nS = Math.floor(nMS/1000) % 60; //如果秒钟大于0 if (nMS < 0){ //获得天数隐藏 $("#dao").hide(); //获得活动截止时间展开 $("#daoend").show(); //否则 }else{ //天数展开 $("#dao").show(); //活动截止时间隐藏 $("#daoend").hide(); //显示天数 $("#RemainD").text(nD); //显示小时 $("#RemainH").text(nH); //显示分钟 $("#RemainM").text(nM); //显示秒钟 $("#RemainS").text(nS); } } //定义方法 $(document).ready(function () { //定义参数 显示出GetRTime()方法 1000毫秒以后启动 var timer_rt = window.setInterval("GetRTime()", 1000); }); </script><body><div class="timerbg"><div id="daoend" style="display: none;">本次活动已结束。</div><div id="dao"><strong id="RemainD"></strong>天<strong id="RemainH"></strong>时<strongid="RemainM"></strong>分<strong id="RemainS"></strong>秒</div></div></body></html>
阅读全文
0 0
- jquery时间倒计时案例
- jquery时间倒计时
- jquery时间倒计时
- jquery 设置团购时间倒计时
- jquery实现LED屏时间倒计时特效
- LED样式的jQuery时间倒计时插件
- 时间倒计时
- 时间倒计时
- 时间倒计时
- 时间倒计时
- 时间倒计时
- 时间倒计时
- jquery 倒计时
- Jquery倒计时
- jquery 倒计时
- jquery倒计时
- Jquery倒计时
- jquery 倒计时
- C语言基本算法四穷举
- liferay7 结合wechat
- 阻塞队列
- 恶意代码分析实战 Lab 6-4 习题笔记
- Statistical language model 统计语言模型
- jquery时间倒计时案例
- MySQL数据库基础
- AutoCompleteTextView的使用及属性详解
- kafka是如何设计的
- HDU
- ValueError: too many values to unpack (expected 2)
- MySQL锁的用法之行级锁
- Pycharm指定JDK路径
- 51nod 1381 硬币游戏