Home > Article > Web Front-end > Methods to disable and undisable page buttons_javascript skills
The concept of timer and delayer
//--Timer
// Timer ID number setInterval(callback function, milliseconds);
// Call the callback function every specified milliseconds
// clearInterval (timer ID number)
// Stop the timer with the specified ID number (actually destroying and releasing resources)
//--Delayer
// Delayer ID number setTimeout (callback function, millisecond interval)
// Starting from the call, wait for the specified number of milliseconds and call the callback function once, then end
// Use clearTimeout to clear the delayer
Rendering:
After the page is opened, the following picture will appear: After that, the button value value will decrease by 1 every 1 second until 0. The stop button content will change to agree
Implementation code: