亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

jQuery實(shí)現(xiàn)倒計(jì)時(shí)功能完整示例

 更新時(shí)間:2020年06月01日 10:28:39   作者:二萌偏  
這篇文章主要介紹了jQuery實(shí)現(xiàn)倒計(jì)時(shí)功能,結(jié)合完整實(shí)例形式詳細(xì)分析了jQuery倒計(jì)時(shí)功能相關(guān)實(shí)現(xiàn)技巧與操作注意事項(xiàng),需要的朋友可以參考下

本文實(shí)例講述了jQuery實(shí)現(xiàn)倒計(jì)時(shí)功能。分享給大家供大家參考,具體如下:

demo代碼:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>chabaoo.cn 時(shí)間倒計(jì)時(shí)</title>
</head>
<body>
<form id="form1" runat="server">
  <div id="show">
  </div>
</form>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
  $(function () {
    TimeDown("show", 3600000)
  });
  /*
   時(shí)間倒計(jì)時(shí)
   TimeDown.js
   */
  function TimeDown(id, value) {
 
    //倒計(jì)時(shí)的總秒數(shù)
    var totalSeconds = parseInt(value / 1000);
 
    //取模(余數(shù))
    var modulo = totalSeconds % (60 * 60 * 24);
    //小時(shí)數(shù)
    var hours = Math.floor(modulo / (60 * 60));
    modulo = modulo % (60 * 60);
    //分鐘
    var minutes = Math.floor(modulo / 60);
    //秒
    var seconds = modulo % 60;
 
    hours = hours.toString().length == 1 ? '0' + hours : hours;
    minutes = minutes.toString().length == 1 ? '0' + minutes : minutes;
    seconds = seconds.toString().length == 1 ? '0' + seconds : seconds;
 
    //輸出到頁面
    document.getElementById(id).innerHTML = hours + ":" + minutes + ":" + seconds;
    //延遲一秒執(zhí)行自己
    if(hours == "00" && minutes == "00" && parseInt(seconds)-1<0){
 
    }else{
      setTimeout(function () {
        TimeDown(id, value-1000);
      }, 1000)
    }
 
  }
</script>
</body>
</html>

運(yùn)行結(jié)果:

感興趣的朋友可以使用在線HTML/CSS/JavaScript代碼運(yùn)行工具http://tools.jb51.net/code/HtmlJsRun測(cè)試上述代碼運(yùn)行效果。

PS:這里再為大家推薦幾款時(shí)間及日期相關(guān)工具供大家參考使用:

在線秒表工具:
http://tools.jb51.net/bianmin/miaobiao

在線日期/天數(shù)計(jì)算器:
http://tools.jb51.net/jisuanqi/date_jisuanqi

在線日期天數(shù)差計(jì)算器:
http://tools.jb51.net/jisuanqi/onlinedatejsq

Unix時(shí)間戳(timestamp)轉(zhuǎn)換工具:
http://tools.jb51.net/code/unixtime

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery日期與時(shí)間操作技巧總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常見事件用法與技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery常見經(jīng)典特效匯總》及《jquery選擇器用法總結(jié)

希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論