zoukankan      html  css  js  c++  java
  • 制作秒表

    1
    2
    3
    4
    <input type="text" name="" id="shuzi" value="00:00:00" /><br />
            <input onclick="ks()" type="button" name="" id="kaishi" value="开始" />
            <input onclick="zt()"   type="button" name="" id="" value="暂停" />
            <input onclick="cz()" type="button" name="" id="" value="重置" />

    毫秒与秒之间的换算  100ms等于一秒

    定义定时器10ms刷新一次 那么1秒钟刷新100次 就是毫秒 定义一个变量n n++  那么毫秒就是n%100(取整)  取余

    秒等于n/100%60  分等于n/6000%60

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    <script>
                var n=0;
                var time=null;
                function xs(){
                    var aaa=document.getElementById("shuzi");
                    n++;
                    var haomiao=parseInt(n%100);
                    var miao=parseInt(n/100%60);
                    var fen=parseInt(n/6000%60);
                    aaa.value=bl(fen)+":"+bl(miao)+":"+bl(haomiao)
                }
                function ks(){//开始
                    clearInterval(time);
                    time=setInterval(xs,10);//定时器    10毫秒刷新一次
                }
                function zt(){//暂停
                    clearInterval(time);//清除定时器
                }
                function cz(){//重置
                    var aaa=document.getElementById("shuzi");
                    aaa.value="00"+":"+"00"+":"+"00";
                    clearInterval(time);//清除定时器
                }
                function bl(ggg){//补零
                    return ggg<10?"0"+ggg:""+ggg
                }
            </script>
  • 相关阅读:
    write(byte[] b, int off, int len)
    getAttribute 与getParmeter 区别
    ServletContext
    SercletConfig 详解
    MYSQL导入数据出现ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
    mybatis在xml文件中处理大于号小于号的方法
    阿里云实名认证接口调试
    js encodeuricomponent base64
    Introspector内存溢出的原理解析
    JVM虚拟机工作原理
  • 原文地址:https://www.cnblogs.com/gaowc/p/10700296.html
Copyright © 2011-2022 走看看