Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let count_down = document.getElementById("number").onclick = function(){
- document.getElementById("label").innerHTML = document.getElementById("input").value;
- const sleep = (time) => {
- return new Promise((resolve) => setTimeout(resolve, time))
- }
- const time_sleep = 1000;
- let a = true;
- const dosomething = async () => {
- for(let i = 1; i < document.getElementById("label").innerHTML ;i--){
- await sleep(time_sleep);
- document.getElementById("label").innerHTML -= 1;
- if(document.getElementById("label").innerHTML <= 1 ){
- document.getElementById("label").innerHTML = 1;
- }
- if (document.getElementById("label").innerHTML <= 1){
- break;
- }
- }
- }
- dosomething();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement