If you want to implement regular execution of some functions on the page, you need to use the following functions for your reference. SetTimeout (script, millisecond); indicates the number of microseconds from which the code is run (only once)
SetInterval (script, millisecond); is the number of microseconds to run the code
Example:
1. Run Once
Second <script type = "text/javascript"> var I = 1; var txt = document. getElementById ("time"); function addT (I) {txt. innerHTML = I;} setTimeout ("addT (I ++)", 1000); script
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
2. Copy and execute
3 seconds <script type = "text/javascript"> var I = 1; var txt = document. getElementById ("time"); function addT (I) {txt. innerHTML = I;} setInterval ("addT (I ++)", 1000); script
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
SetTimeout can also be executed repeatedly.
Second <script type = "text/javascript"> var I = 1; var txt = document. getElementById ("time"); function addT (I) {txt. innerHTML = I; setTimeout ("addT (I ++)", 1000);} addT (I); script
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]