Home >Web Front-end >JS Tutorial >JavaScript study notes: timer_basic knowledge

JavaScript study notes: timer_basic knowledge

WBOY
WBOYOriginal
2016-05-16 16:18:351102browse

Timer 1

Used to specify a program to be executed after a specific period of time.

setTimeout():

Format: [timer object name=] setTimeout(“”, milliseconds)

Function: Execute once.

Example:

Copy code The code is as follows:




timer1.html










Timer 2

Continuously execute the expression repeatedly at certain intervals.

setInterval():

Format: [timer object name=] setInterval(“”, milliseconds)

Function: Repeat until the window or frame is closed or clearInterval is executed.

clearInterval():

Format: clearInterval (timer object name)

Function: Terminate timer

Example:

Copy code The code is as follows:




timer2.html







0



The above is the entire content of this article, I hope you all like it

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