Home  >  Article  >  Web Front-end  >  The difference between javascript setTimeout and setInterval_Basic knowledge

The difference between javascript setTimeout and setInterval_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 18:39:41956browse

The setTimeout method is a timing program, that is, what to do after a certain time. Pull it down when you're done.
The setInterval method means to repeatedly perform an operation at a certain interval.

If you use setTimeout to implement the function of setInerval, you need to call yourself regularly in the executing program. If you want to clear the counter, you need to call different clearing methods according to the method used:

For example:
tttt=setTimeout('northsnow()',1000);
clearTimeout(tttt);

Or:
tttt=setInterval('northsnow()',1000);
clearInteval(tttt);

For example:

Copy code The code is as follows:






Or:
Copy code The code is as follows:





Statement:
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