123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <script>
- // 定时函数
- // window.setTimeout(function(){
- // console.log("hello world");
- // },3000)
- // 定时函数 里面接受两个参数 第一个为回调函数,第二个参数是时间毫秒为单位 1000毫秒=1秒
- // setTimeout(function(){
- // },3000)
- // function foo(){
- // console.log("hell world");
- // }
- // setTimeout(foo,3000);
- // 定时函数 他会循环之行 会根据设定的时间 间隔 循环
- // setInterval(function(){
- // console.log("hello world");
- // },1000)
- var i = 0;
- var set1 = setInterval(function(){
- i++;
- console.log(i)
- if(i==10){
- clearInterval(set1);
- }
- },1000)
- </script>
- </body>
- </html>
|