Effect:

Display the current time and automatically grow
Add a timer for the button (for start and pause)
Effect:

#Click the start button to count from 0 and add 1 every second. Click the button to stop and maintain the current state.
Summary:
1. setInterval(code, interaction time);
Parameters: code: can be a function name or code string; interaction time: set the interaction time
clearInterval(id_from_setInterval);
Parameter: ID value returned by setInterval().
2. setTimeout (code, delay time);
Parameters: code: can be a function name or code string; delay time: set the delay time
clearTimeout (id_from_setTimeout) ;
Parameter: ID value returned by setTimeout().
The above is the detailed content of Implementation of javascript timer. For more information, please follow other related articles on the PHP Chinese website!