Home > Web Front-end > JS Tutorial > body text

A brief analysis of usage examples of setTimeout() and clearTimeout() in js_javascript skills

WBOY
Release: 2016-05-16 15:59:36
Original
1262 people have browsed it

This article analyzes the usage of setTimeout() and clearTimeout() in js with examples. Share it with everyone for your reference. The specific analysis is as follows:

The setTimeout() method is used to call a function or calculate an expression after a specified number of milliseconds.

clearTimeout() method can cancel the timeout set by setTimeout() method.

<input type = text id = aaa >
<input type = button value = stop id = bb onclick = bb()>
<script>
<!--
var iTime
function aa()
{
 aaa.value += "!";
 iTime=setTimeout("aa()",600);
}
function bb()
{
 if (iTime !="")
 clearTimeout(iTime);
}
aa()
-->
</script>
Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template