• js计时器


    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>计时器</title>
    <script type="text/javascript">
    var t=0;
    var t1;
    //定义$函数获取id
    function $(id){
      return document.getElementById(id);
    }
    //开始计时
    function timeStart(){
      hour = parseInt(t / 3600);// 时
      min = parseInt(t / 60);// 分
      if(min>=60){
        min = min % 60;
      }
      lastsecs = t % 60; //秒
      if(lastsecs<10){lastsecs = '0' + lastsecs;}
      if(min<10){min = '0' + min;}
      if(hour<10){hour = '0' + hour;}
      //在输入框显示计时
      $('txt').value = hour + ":" + min + ":" + lastsecs;
      t = t + 1;
      t1 = setTimeout('timeStart()',1000)
      $('start').style.display = "none";
      $('stop').style.display = "";
    }
    //停止计时
    function timeStop(){
      clearTimeout(t1)
      $('start').style.display = "";
      $('stop').style.display = "none";
    }
    //清除
    function clearAll(){
      t=0;
      $('txt').value= "00:" + "00:" + "00";
      clearTimeout(t1);
      $('start').style.display ="";
      $('stop').style.display = "none";
    }
    </script>
    </head>
    <body>
    <p>点击“开始计时”按钮启动计时器开始进行计时,从 0 开始,点击“停止计时”按钮停止计时。</p>
    <form>
    <input type="text" id="txt" value="00:00:00" />
    <input type="button" value="开始计时" id="start" onClick="timeStart()" />
    <input type="button" value="停止计时" style="display:none" id="stop" onClick="timeStop()" />
    <input type="button" value="清除" onClick="clearAll()" />
    </form>
    </body>
    </html>

  • 相关阅读:
    CSS 中z-index全解析(摘自阿里西西)
    Video标签的使用
    HTML标签解释大全
    在html中插入音频
    ABAP更改现有程序
    乱糟糟的笔记
    ABAP提示信息对话框
    【学习】几种查找增强的方法
    【学习】ABAP OLE 对EXCEL的处理
    【转载】ABAP-如何读取内表的字段名称
  • 原文地址:https://www.cnblogs.com/Sillynoob/p/4848642.html
Copyright © 2020-2023  润新知