• 倒计时.js


    function getDouble(n){

       if(n > 9){

           return n;

       }else{

           return "0" + n;

    function diffTime(startTime, endTime) {

        var dTime = endTime - startTime;

        var day,hour,minute,second;

        var interval =  dTime / 1000;

        second = getDouble(Math。floor(interval % 60));

        minute = getDouble(Math。floor(interval / 60 % 60));

        hour = getDouble(Math。floor(interval / 60 / 60 % 24));

        day = getDouble(Math。floor(interval / 60 / 60 / 24));

        if(dTime > 0) {

            return{

              day: day,

              hour: hour,

              minute: minute,

              second: second

          } else {

            return clearInterval(timeId);

          }
        }

    var endTime = new Date(“2020-11-11 0:0:0”);

    var day = document。querySelectir(“#day”);

    var hour = document。querySelectir(“#hour”);

    var minute = document。querySelectir(“#minute“);

    var second = document。querySelectir(“#second“);

    function countDown(){

      var startTime = new Date();

      var diffTime = diffTime(startTime,endTime);

      if = diffTime

          day。innerHTML = diffTime。day;

          hour。innerHTML = diffTime。hour;

          minute。innerHTML = diffTime。minute;

          second。innerHTML = diffTime。second;

    countDown();

    var timeId = setInterval(countDown, 1000);

    <span id = "day">00</span>

    <span id = "hour">00</span>

    <span id = "minute">00</span>

    <span id = "second">00</span>

  • 相关阅读:
    吉他音阶笔记(以C调为基准)
    小程序页面跳转问题
    Adobe-premierej剪辑视频分辨率问题及格式转换画面质量分辨率
    关于ps抠图问题,制作公章,公章的复制
    premiere视频剪辑关于导出视屏分辨率的问题
    最后一个单词的长度
    10.两个链表的交叉
    软件工程——个人总结
    软件工程——团队专业4
    软件工程——团队答辩
  • 原文地址:https://www.cnblogs.com/pxxdbk/p/12503282.html
Copyright © 2020-2023  润新知