• setTimeout()执行时序


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>SETTIMEOUT</title>
    <script type="text/javascript">
    var len=4;
    var t = null;
    while(len--){
    t = setTimeout("showinfo(len,t)",2000);
    document.write(len+"  ");
    }
    document.write("<br/>");
    document.write("    abc"+len);

    function showinfo(num1,num2)
    {
    document.write("len:"+num1+"  t:"+num2);
    }
    </script>
    </head>

    <body>
    <div></div>
    </body>

    </html>

    网页显示:

    首先输出:

    3  2  1  0  
        abc-1

    2s后输出:

    len:-1  t:10

    setTimeout()启动后,与其他字段同时执行。

  • 相关阅读:
    python中神之bug
    常用好的软件
    远程登录
    centos7改静态ip
    SpringMVC归纳
    mysql数据库操作手册
    MyBatis归纳
    Maven归纳
    maven操作手册
    java知识库
  • 原文地址:https://www.cnblogs.com/archermeng/p/7537587.html
Copyright © 2020-2023  润新知