jquery disable a button for a specific time

前端 未结 4 832
攒了一身酷
攒了一身酷 2020-12-17 21:34

i want to disable a button for a specific time. how can i do that?

4条回答
  •  情话喂你
    2020-12-17 22:25

    Try this.

    (function(){
    $('button').on('click',function(){
    var $this=$(this);
            $this
                .attr('disabled','disabled');
                 setTimeout(function() {
                 $this.removeAttr('disabled');
                 }, 3000);
          });
     })();
    

    You can find a working example here http://jsfiddle.net/informativejavascript/AMqb5/

提交回复
热议问题