Skip to content Skip to sidebar Skip to footer

Disable A Button After One Click And Is Should Work For All Type Of Browsers?

function disableLbtSend() { document.getElementById('<%=Buttonclick.ClientID%>').disabled= true; } window.onbeforeunload = disableOgSend; I want to disable button after

Solution 1:

try this using jquery:

functiondisableLbtSend() { 
    $('#' + '<%= Buttonclick.ClientID %>').attr("disabled", "disabled");
}

Solution 2:

You can add a click handler to the button which removes itself after being triggered:

functionclickOnceHandler(e) {
  // Do something.alert('Do something then disable the button');

  // Disable your button.
  e.target.disabled = true;

  // Remove this click handler.
  e.target.removeEventListener(e.type, clickOnceHandler);
}

const buttons = document.querySelectorAll('button');

for (let i = 0; i < buttons.length; i++) {
  buttons[i].addEventListener('click', clickOnceHandler);
}

functionclickOnceHandler(e) {
  // Do something.alert('Do something then disable the button');

  // Disable your button.
  e.target.disabled = true;

  // Remove this click handler.
  e.target.removeEventListener(e.type, clickOnceHandler);
}
<buttontype="button">Click Once</button><buttontype="button">Click Once</button><buttontype="button">Click Once</button>

Solution 3:

try user jquery

functiondisableLbtSend() {
  $('#' + '<%= Buttonclick.ClientID %>').prop('disabled', true);
}

Post a Comment for "Disable A Button After One Click And Is Should Work For All Type Of Browsers?"