Advertisement
stilian1231231

Untitled

Dec 17th, 2022
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let count_down = document.getElementById("number").onclick = function(){
  2.  
  3.   document.getElementById("label").innerHTML = document.getElementById("input").value;
  4.  
  5.   const sleep = (time) => {
  6.     return new Promise((resolve) => setTimeout(resolve, time))
  7.    
  8.   }
  9.  
  10.   const time_sleep = 1000;
  11.   let a = true;
  12.  
  13.   const dosomething = async () => {
  14.     for(let i = 1; i < document.getElementById("label").innerHTML ;i--){
  15.       await sleep(time_sleep);
  16.       document.getElementById("label").innerHTML -= 1;
  17.      
  18.      
  19.       if(document.getElementById("label").innerHTML <= 1 ){
  20.         document.getElementById("label").innerHTML = 1;
  21.       }
  22.  
  23.       if (document.getElementById("label").innerHTML <= 1){
  24.         break;
  25.       }
  26.     }
  27.   }
  28.  
  29.   dosomething();
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement