Home > Article > Web Front-end > A brief analysis of usage examples of setTimeout() and clearTimeout() in js_javascript skills
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>
I hope this article will be helpful to everyone’s JavaScript programming design.