当前位置:网站首页>Functions in setinterval cannot have parentheses
Functions in setinterval cannot have parentheses
2022-06-24 07:02:00 【Haitian Eagle】
while The cycle will get stuck CPU, To use setInterval Instead of .
Only once
<script>
var i=0;
function say() {
i++;
document.write(i+'<br>');
if (i==10)
clearInterval(id);
}
var id = setInterval(say(), 100);
</script>Change to
<script>
var i=0;
function say() {
i++;
document.write(i+'<br>');
if (i==10)
clearInterval(id);
}
var id = setInterval(say, 100);
</script>setInterval Method is executed only once after the parameter is extracted
边栏推荐
- Database stored procedure begin end
- On BOM and DOM (6): bit value calculation of DOM objects and event objects, such as offsetx/top and clearx
- Maui uses Masa blazor component library
- 【云驻共创】华为云HCIA-IoT V2.5培训系列内容之物联网概览
- Let's talk about BOM and DOM (5): dom of all large Rovers and the pits in BOM compatibility
- Rockscache schematic diagram of cache operation
- What is the OSI seven layer model? What is the role of each layer?
- JSON online parsing and the structure of JSON
- 【JUC系列】Executor框架之CompletionFuture
- How to make a website? What should I pay attention to when making a website?
猜你喜欢

Programmers use personalized Wallpapers

leetcode:1856. 子数组最小乘积的最大值

Rockscache schematic diagram of cache operation

The data synchronization tool dataX has officially supported reading and writing tdengine

缓存操作rockscache原理图

目标5000万日活,Pwnk欲打造下一代年轻人的“迪士尼乐园”

Intelligent Vision Group A4 paper recognition example

puzzle(019.1)Hook、Gear

记录--关于JSP前台传参数到后台出现乱码的问题

Counter attack of flour dregs: MySQL 66 questions, 20000 words + 50 pictures
随机推荐
oracle sql综合运用 习题
leetcode:1856. Maximum value of minimum product of subarray
Let's talk about BOM and DOM (5): dom of all large Rovers and the pits in BOM compatibility
为什么要用lock 【readonly】object?为什么不要lock(this)?
机器人迷雾之算力与智能
C language student management system - can check the legitimacy of user input, two-way leading circular linked list
数据库 存储过程 begin end
【愚公系列】2022年6月 ASP.NET Core下CellReport报表工具基本介绍和使用
. Net7 miniapi (special part):preview5 optimizes JWT verification (Part 1)
Working principle of online video server selection method for online video platform
leetcode:85. 最大矩形
展锐芯片之GPU频率
leetcode:84. The largest rectangle in the histogram
What is JSP technology? Advantages of JSP technology
Brief introduction of domain name registration
跳跃游戏II[贪心练习]
【问题解决】The connection to the server localhost:8080 was refused
Spark累加器和廣播變量
华为云低时延技术的九大绝招
How do I check the IP address? What is an IP address
https://jingyan.baidu.com/article/b2c186c86c3590c46ef6ffe5.html