티스토리 뷰

JAVASCRIPT/유용기능

[Javascript] sleep trigger code

jeongah story 2020. 8. 11. 10:57
function sleep(t){
   return new Promise(resolve=>setTimeout(resolve,t));
}

var doubleClick = 0;
async function allImgDownload() {
	let imgs = document.querySelectorAll(".item-img-pop");

	doubleClick = 1;
	if( doubleClick == 1){
		for (let i =0; i < imgs.length; i++) {        
			await sleep(1000);
			imgs[i].click();
		}
      	doubleClick = 0;
	} else {
		return false;
	}
}

 

 

댓글
© 2018 eh2world