Home > Web Front-end > JS Tutorial > A brief analysis of usage examples of setTimeout() and clearTimeout() in js

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

高洛峰
Release: 2017-02-08 16:04:53
Original
1169 people have browsed it

This article mainly introduces the usage of setTimeout() and clearTimeout() in js, and analyzes the functions and usage skills of setTimeout() and clearTimeout() in the form of examples. Friends in need can refer to 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:

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

clearTimeout() method can be canceled The timeout set by the 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

For more related articles on the usage examples of setTimeout() and clearTimeout() in js, please pay attention to the PHP Chinese website!

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