js 计时器

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>js15.html</title>
    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

    <script type="text/javascript">
    
    var sec = 0;
    var timeId = setInterval("count();", 1000);
    
    function count()
    {
        document.getElementById("num").innerHTML = sec++;
    }
    
    function stopCount()
    {
        clearInterval(timeId);
    }
    
    </script>

  </head>
  
  <body>
    
    <font color="red" id="num">0</font>秒钟
    
    <input type="button" value="停止" onclick="stopCount();">
    
</html>

各种javascript时间问题,可以参考此处。。。

珍惜现在,珍惜每一分,每一秒。 从不放弃,坚持。。。。。
原文地址:https://www.cnblogs.com/feiguo/p/3682081.html