zoukankan      html  css  js  c++  java
  • 设定事件间隔和延迟

    <script type="text/javascript">
    var t=self.setInterval("clock()", 50);
    function clock(){
        var time=new Date();
        document.getElementById("clock").value=time;
    }
    
    function timeMsg(){
        iSecond=Math.ceil((Math.random()*10));
        var t=setTimeout("log()", iSecond*1000);
    }
    function log(){
        $("#log").html("时间延迟:"+iSecond+"seconds!")
    }
    </script>
    </head>
    <body>
        <h2>jQuery设定时间间隔的方法</h2>
        <input type="text" id="clock" size="36"/>
        <button onclick="int=window.clearInterval(t)">stop interval</button>
    
        <h2>jQuery设定时间延迟的方法</h2>
        <form>
            <input type="button" value="Displayed timed alertbox!" onclick="timeMsg()"/>
        </form>
        <p>Click on the button above.An alert box will be displayed after 5 seconds.</p>
        <div id="log"></div>
    </body>

    setInterval(code,millisec[,”lang”]);
    当中code參数表示要调用的函数或要运行的代码串,millisec參数表示周期性运行或调用code之间以毫秒计的时间间隔
    setTimeout(code,millisec[,”lang”])
    当中code參数表示要调用的函数或要运行的代码串,millisec參数表示在运行前需等待的毫秒数,code仅仅运行一次。若要多次调用,必须使用setInterval()或让code自身再次调用setTimeout()函数

  • 相关阅读:
    mongodb的热备工具pbm-agent
    注释
    mongodb的启动配置查询serverCmdLineOpts
    副本集状态
    分片集群的serverStatus监控
    副本集的replSetGetStatus监控
    京东
    副本集的replSetGetConfig监控
    mysql的replace函数
    副本集的serverStatus监控
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/5157123.html
Copyright © 2011-2022 走看看