首页 > 代码库 > js定时器案例

js定时器案例

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>定时器案例</title>
    <script>
        var myCount = 5;
        function count() {
            document.getElementById("test").innerText = myCount+"秒后隐藏";
            myCount--;
            if (myCount == 0) {
                document.getElementById("test").innerHTML = "已经隐藏";
                document.getElementById("tcdiv").style.display="none";
                return;
            }
            setTimeout("count()", 1000);
        }
</script>
</head>
<body onLoad="setTimeout(‘count()‘,10);">
    <form id="form1" runat="server">
    
       <div id="test"></div>
       <div id="tcdiv" style="width:200px; height:100px; border: thin solid #ccc">
       
       </div>
    </form>
</body>
</html>


本文出自 “10975329” 博客,请务必保留此出处http://10985329.blog.51cto.com/10975329/1868878

js定时器案例