JS时间倒计时
来源:互联网 发布:php集成环境哪个好 编辑:程序博客网 时间:2024/05/02 09:26
<pre name="code" class="html"><html> <head> <title>倒计时</title> <!--以下为css样式--> <style type= "text/css"> .daojishi h2 { font-family:Helvetica, Microsoft YaHei, Arial, sans-serif; font-size:14px; margin-bottom:5px; color:#151515; } .daojishi #timer { font-family:Helvetica, Microsoft YaHei, Arial, sans-serif; font-size:14px; color:#151515; font-weight:bold; } </style> <script type = "text/javascript" src = "timer.js"> </script> </head> <body onload = "timer()"> <div class = "daojishi"> <h2>剩余时间为:</h2> <div id = "timer"> </div> </div> </body> </html>
function timer() { var ts = (new Date(2018, 11, 11, 9, 0, 0)) - (new Date());//计算剩余的毫秒数 var dd = parseInt(ts / 1000 / 60 / 60 / 24, 10);//计算剩余的天数 var hh = parseInt(ts / 1000 / 60 / 60 % 24, 10);//计算剩余的小时数 var mm = parseInt(ts / 1000 / 60 % 60, 10);//计算剩余的分钟数 var ss = parseInt(ts / 1000 % 60, 10);//计算剩余的秒数 dd = checkTime(dd); hh = checkTime(hh); mm = checkTime(mm); ss = checkTime(ss); document.getElementById("timer").innerHTML = dd + "天" + hh + "时" + mm + "分" + ss + "秒"; setInterval("timer()",1000); } function checkTime(i) { if (i < 10) { i = "0" + i; } return i; }
0 0
- 时间倒计时 JS
- js时间倒计时
- JS 时间倒计时
- js时间倒计时
- JS 实现时间倒计时
- JS 时间倒计时
- js时间倒计时 (二)
- js时间倒计时(三)
- js 时间倒计时
- JS时间倒计时
- js时间倒计时
- JS时间倒计时
- js 时间倒计时
- js活动时间倒计时
- js实现时间倒计时
- js 倒计时时间定时器
- js获取客户时间倒计时,js获取服务器端时间倒计时
- js实现考试时间倒计时
- onActivityResult在android中的用法
- Porcelain codeforce (背包)
- 扩展UIImage
- 算法——排序之插入排序
- MySQL索引的Index method中btree和hash的区别
- JS时间倒计时
- Jquery无刷新,解析json
- phpstorm和firefox协同调试web(html)+php语句(或web(html)跳转到php语句)
- linux c/c++ 帮助 help
- PHP中$_SERVER的详细参数与说明
- Majority Number——算法练习
- Ubuntu自定义命令
- MVVM架构介绍(转)
- tomcat下中文乱码的问题