Home >Web Front-end >JS Tutorial >Example introduction to the difference between interval and setTimeOut in javascript_Basic knowledge

Example introduction to the difference between interval and setTimeOut in javascript_Basic knowledge

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 16:55:301069browse

setTimeout(code, millisec) //- Execute the code after the specified time

code is required;

millisec is required;

clearTimeout(setTimeoutId) //- Cancel setTimeout()

setInterval(code, millisec); //Loop the execution code within the specified interval milliseconds

code is required;

millisec is required;

clearInterval(intervalId) ;

Use setTimeout(code, millisec) to achieve the setInterval effect, you only need to nest the calling method;

The following is a countdown page

Copy code The code is as follows:





Untitled Document








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