zoukankan      html  css  js  c++  java
  • 简单时间定时器

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>时间定时器</title>
    <script type="text/javascript">
    var time;//定义一个全局时间变量
    function start(){ //执行start()函数
    time=window.setInterval(function(){
    var t=new Date();//创建时间对象
    var now=t.toLocaleString();//获取当前时间
    var result=document.getElementById("result");//根据id查询节点
    result.innerHTML=now;//获取时间结果

    },1000);//采用匿名函数,1秒变化一次
    }
    function stop(){
    window.clearInterval(time);
    }
    </script>
    </head>
    <body>
    <div>
    <span id="result"></span><br><br><br>
    <button type="button" onclick="start()">开始</button>
    <button type="button" onclick="stop()">停止</button>
    </div>
    </body>
    </html>

  • 相关阅读:
    Linux
    Cookie & Session
    HTTP
    HTTP
    抓包工具
    抓包工具
    抓包工具
    python
    python
    python
  • 原文地址:https://www.cnblogs.com/liyangqiao/p/13206862.html
Copyright © 2011-2022 走看看