disable an Asp.net Button then enable it after 5 seconds using java script

前端 未结 2 1169
执笔经年
执笔经年 2021-01-22 22:29

I want to run an Asp.net button click event (After clicking it) then disable it for 5 seconds and enable it again. I use this java script code but the click event code does not

2条回答
  •  无人及你
    2021-01-22 23:11

    check this out. https://jsfiddle.net/9ds9mL1v/5/

    $("#Button1").click(function(){
    var button =$(this);
      var oldValue = $(this).value;
    
        button.attr('disabled', true);
        button.value = 'Wait 5 sec';
    
        setTimeout(function () {
            button.value = oldValue;
            button.removeAttr('disabled');
        }, 5000)
    
    
    });
    

提交回复
热议问题