I have this code, I tried with the setTimeout, promises and callback functions with no luck.
document.querySelectorAll("input").forEach((el, i) => {
setTimeout(() => {
el.checked = true
}, i * 300);
})
Any help is welcome.
The setup()
function sets a timeout on each checkbox. When the last one fires, it sets them all up again:
function setup() {
document.querySelectorAll("input").forEach((el, i) => {
setTimeout(() => {
el.checked = ! el.checked
if ( i+1 == document.querySelectorAll("input").length) {
setup()
}
}, i * 300);
}
)}
setup()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.