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

前端 未结 2 1170
执笔经年
执笔经年 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)
    
    
    });
    
    0 讨论(0)
  • 2021-01-22 23:22

    You can try this:

    function lockoutSubmit(button) {
        var oldValue = button.value;
    
        setTimeout(function () {
            button.setAttribute('disabled', true);
            button.value = 'Wait 5 sec';
        }, 0);
    
        setTimeout(function () {
            button.value = oldValue;
            button.removeAttribute('disabled');
        }, 5000);
    }
    
    0 讨论(0)
提交回复
热议问题