zoukankan      html  css  js  c++  java
  • js计数器

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>计时器</title>
    
    <script type="text/javascript">
      var num=0;
      function startCount() {
        document.getElementById('count').value=num;
        num=num+1;
        setTimeout("startCount()",1000);
         
      }
      
    </script>
    </head>
    <body>
    <form>
    <input type="text" id="count" onclick="startCount()"/>
    </form>
    </body>
    </html>

    实现数字自动增长。

    增加start和stop控制按钮

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>计时器</title>
    <script type="text/javascript">
      var num=0;
      var i;
      function startCount(){
        document.getElementById('count').value=num;
        num=num+1;
        i=setTimeout("startCount()",1000);
      }
      function stopCount(){
        clearTimeout(i);
      }
    </script>
    </head>
    <body>
      <form>
        <input type="text" id="count" />
        <input type="button" value="Start"  onclick="startCount()"/>
        <input type="button" value="Stop"  onclick="stopCount()" />
      </form>
    </body>
    </html>
  • 相关阅读:
    多线程-上
    IO流之序列化
    IO流之标准输入输出流
    IO流之BufferedReader/BufferedWriter
    IO流之转换流
    IO流之字符输入输出流
    IO流之字节输入输出流
    JS Flex布局
    MSSQL case when
    钉钉审批流API
  • 原文地址:https://www.cnblogs.com/superxuezhazha/p/6362369.html
Copyright © 2011-2022 走看看