How would I disable all links with the button
class after they are clicked once? I'd like to be able to do this in one place, and not have to change all of them individually.. any ideas?
So far I got this:
$("a.button").click(function() { $(this).attr("disabled", "disabled"); }); $("a[disabled]").click(function() { return false; });
but the second event isn't firing..
Present Code click(function (e) { // Prevent button from double click var isPageValid = Page_ClientValidate(); if (isPageValid) { if (isOperationInProgress == noIndicator) { isOperationInProgress = yesIndicator; } else { e.
It is still possible to disable a link by following 3 steps: remove the href attribute so that it can no longer receive the focus. add a role="link" so that it is always considered a link by screen readers. add an attribute aria-disabled="true" so that it is indicated as being disabled.
This is what I would try:
$("a.button").one("click", function() { $(this).click(function () { return false; }); });
Bind all the links with class "button". Run the anonymous function only once (hence "one"), which rebinds the link to return false.
If you want to keep it looking more like what you have, try this:
$("a.button").click(function() { $(this).attr("disabled", "disabled"); }); $(document).click(function(evt) { if ($(evt.target).is("a[disabled]")) return false; });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With