<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>定时器 间隔调用setInterval</title> <!-- setInterval("代码a",n);每隔n毫秒后执行以此代码a clearInterval();清除间隔调用 --> </head> <body> <script> var x; x=setInterval("console.log(‘每秒打印一次‘)",1000);//设置间隔调用 setTimeout("clearInterval(x)",3000);//设置延时调用:在3秒后清除间隔调用 </script> </body> </html>
原文地址:https://www.cnblogs.com/vinson-blog/p/12077410.html
时间: 2024-11-09 03:38:58