Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method for JavaScript to delete the delayer

2025-03-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what is the method of JavaScript deletion delay timer". The explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the method of JavaScript deletion delay timer".

JavaScript delete the delay: 1, use the "clearInterval (id)" statement, you can delete the delay defined by setInterval (); 2, use the "clearTimeout (id)" statement, you can delete the delay defined by setTimeout ().

The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.

JavaScript timers, also known as timers, sometimes referred to as "timers", are used to perform certain tasks after a specified period of time, similar to the alarm clock in our lives.

In JavaScript, we can use delays to delay the execution of some code, or to repeat some code at regular intervals.

There are two ways to set timers in JavaScript, namely setTimeout () and setInterval (), and there are also two ways to delete delayers:

ClearInterval () cancels the timeout set by setInterval ().

ClearTimeout () cancels the timeout set by the setTimeout () method.

ClearInterval ()

The clearInterval () method cancels the timeout set by setInterval ().

Syntax:

ClearInterval (id)

The argument to the clearInterval () method must be the ID value returned by setInterval ().

Example:

Var int=self.setInterval ("clock ()", 50) function clock () {var t=new Date () document.getElementById ("clock") .value=t}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report