一個不錯的js html頁面倒計時可精確到秒
更新時間:2014年10月22日 17:08:42 投稿:whsnow
這篇文章主要介紹了一個不錯的js html頁面倒計時可精確到秒,很簡單,但和實用,需要的朋友可以參考下
一個不錯的js html頁面倒計時可精確到秒,很簡單,但和實用
<!doctype html> <html> <head> <meta charset="utf-8"> </head> <body> <DIV id="CountMsg" class="HotDate"> <span id="t_d">00天</span> <span id="t_h">00時</span> <span id="t_m">00分</span> <span id="t_s">00秒</span> </DIV> <script type="text/javascript"> function getRTime(){ var EndTime= new Date('2014/10/23 10:00:00'); //截止時間 var NowTime = new Date(); var t =EndTime.getTime() - NowTime.getTime(); /*var d=Math.floor(t/1000/60/60/24); t-=d*(1000*60*60*24); var h=Math.floor(t/1000/60/60); t-=h*60*60*1000; var m=Math.floor(t/1000/60); t-=m*60*1000; var s=Math.floor(t/1000);*/ var d=Math.floor(t/1000/60/60/24); var h=Math.floor(t/1000/60/60%24); var m=Math.floor(t/1000/60%60); var s=Math.floor(t/1000%60); document.getElementById("t_d").innerHTML = d + "天"; document.getElementById("t_h").innerHTML = h + "時"; document.getElementById("t_m").innerHTML = m + "分"; document.getElementById("t_s").innerHTML = s + "秒"; } setInterval(getRTime,1000); </script> </body> </html>
相關(guān)文章
JavaScript實現(xiàn)HTML5游戲斷線自動重連的方法
這篇文章主要介紹了JavaScript實現(xiàn)HTML5游戲斷線自動重連的方法,需要的朋友可以參考下2017-09-09使用bootstrapValidator插件進行動態(tài)添加表單元素并校驗
動態(tài)添加表單元素,并調(diào)用bootstrapValidator的方法為表單添加校驗規(guī)則,調(diào)用addField()方法實現(xiàn)功能。下面通過本文看下具體實現(xiàn)方法吧2016-09-09JavaScript XML實現(xiàn)兩級級聯(lián)下拉列表
用xml作為存儲容器,不用數(shù)據(jù)庫,速度和效率高些。2008-11-11Bootstrap實現(xiàn)可折疊分組側(cè)邊導(dǎo)航菜單
這篇文章主要介紹了Bootstrap實現(xiàn)可折疊分組側(cè)邊導(dǎo)航菜單的相關(guān)資料,需要的朋友可以參考下2018-03-03