A Brief Analysis of setTimeout of and clearTimeout of in js
- 2020-06-12 08:27:15
- OfStack
This paper analyzes the usage of setTimeout() and clearTimeout() in js. Share to everybody for everybody reference. The specific analysis is as follows:
The setTimeout() method is used to call a function or evaluate an expression after a specified number of milliseconds.
The clearTimeout() method cancels 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>
I hope this article has been helpful for your javascript programming.