First introduce these two functions
1. setInterval()
Calls a function or expression at a specified cycle, executing multiple times . (time unit: ms)
timer = setInterval("content = document.getElementById("input_content").value;", 800) // execute the js statement
every 0.8s timer = setInterval(showHint, 800) // execute the showHint function every 0.8s
clearTimeout(timer) // cancel the timer
二、setTimeout()
Execute a function or expression after a period of time, once . (time unit: ms)
timer = setTimeout("content = document.getElementById("input_content").value;", 800) // execute the js statement once
in 0.8s timer = setTimeout(showHint, 800) // execute the showHint function after 0.8s
clearTimeout(timer) // cancel the timer
Remember, you can't write this with a function as an argument: functionname(). In this way, the function will be executed directly, and the delay effect will not be achieved, just pass in the function name.
If the called function needs to pass in parameters, it should be written like this:
function mytest(webName){ console.log (webName); } setInterval("mytest('Ant Tribe')",800);