Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Disable button and reenable it after 5 seconds

Tags:

javascript

I want to disable my button on click and then reenable in after 5 seconds but its not working properly.

  function submitPoll(id){
      document.getElementById("votebutton").disabled = true;
      document.getElementById("votebutton").delay(5000).disabled = false;
  }
like image 838
Thomas Bang Thomas Gaming Avatar asked May 31 '15 14:05

Thomas Bang Thomas Gaming


1 Answers

.delay is jQuery. You can simply use setTimeout in Javascript.

function submitPoll(id){
      document.getElementById("votebutton").disabled = true;
      setTimeout(function(){document.getElementById("votebutton").disabled = false;},5000);
  }
like image 177
Zee Avatar answered Nov 14 '22 20:11

Zee