jquery - How to make button unclickable after it is being clicked? -


i want after button clicked, unclickable few seconds, how can it? want write code buttons, not one. so, need that:

$(document).ready(function() {           $('input[type="button"]').click(function() {         $(this).css("hidden: true");         delay(3);         $(this).css("hidden: normal");     })     }) 

it pseudo-code, give me hand?

with jquery...

$(document).ready(function() {           $('input[type="button"]').click(function() {         var input = this;         input.disabled = true;         settimeout(function() {            input.disabled = false;         }, 3000);      });     }); 

jsfiddle.

without jquery...

document.addeventlistener('domcontentloaded', () => {           document.queryselectorall('input[type="button"]')     .addeventlistener('click', (e) => {         let input = e.target;         input.disabled = true;         settimeout(function() {            input.disabled = false;         }, 3000);      });     }); 

alternatively capture clicks on persistent ancestor element , check if they're input[type="button"] types. prevents attaching multiple events each element.


Comments