wait for time javascript
//code before the pause
setTimeout(function(){
//do what you need here
}, 2000);
wait for time javascript
//code before the pause
setTimeout(function(){
//do what you need here
}, 2000);
wait until something happens javascript
//1st methode : not good enough : very slow
const poller=setInterval(()=>{
//if you want use async function
// return new Promise((resolve, reject) => {
let bear=document.querySelector('ul.bears li')
if(bear){
console.log(bear)
clearInterval(poller)
// resolve(bear)
}
// })
},2000)
//2sd methode : (we will use mutation observer)
const observer= new MutationObserver((mutations)=>{
mutations.forEach((mutation)=>{
if(mutation.addedNodes.lenght){
console.log(mutation.addedNodes[0])
}
})
})
// the elelemtn you wanna to observe
const bears=document.querySelector('ul.bears')
observer.observe(bears,{childList:true})
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us