JavaScript-time timer setting and canceling

Start one-time timer -setTimeout ()

One-time timer, called once will create and execute a timer once.

format:

setTimeout (call method milliseconds);

Example:

effect:

Stop-time timer clearTimeout ()

setTimeout method to create a timer at the same time, also returns a timer ID, which ID represents the timer.

This timer ID in the current page is not repeated.

We can clearTimeout method, specify a one-time timer is stopped

format:

the clearTimeout (timer ID);

Example:

effect:

Because immediately after the timer setting canceled, so there is no effect.

Published 867 original articles · won praise 379 · views 790 000 +

Guess you like

Origin blog.csdn.net/a772304419/article/details/104089020