JS延迟执行

Posted 暗里着迷

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JS延迟执行相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <script type="text/javascript">
        for(var i = 0 ; i < 10; i++){
            setTimeout((function(i){
              return function(){ console.log(i);}
            })(i), i*1000);
        }
    </script>
</head>
<body>

</body>
</html>

 

以上是关于JS延迟执行的主要内容,如果未能解决你的问题,请参考以下文章