Javascript Disable button and reenable it after 5 seconds

前端 未结 2 1856
日久生厌
日久生厌 2021-01-06 18:52

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

  function submitPoll(id){
      document.getElementB         


        
2条回答
  •  悲哀的现实
    2021-01-06 19:23

    .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);
      }
    

提交回复
热议问题