'How can we disable a .NET WebForms (.aspx file) LinkButton in Google Chrome
I need to disable a LinkButton in a .aspx file using jQuery depending on the value. The button gets disabled in IE 8. But in Google Chrome it is not disabled.
Code:
$(".grid-prev-btn").addClass('ui-state-disabled').attr('disabled', true);
Please give me solution for this issue
I am trying to disable link button for a particular condition it gets disabled in Internet Explorer but in Chrome browser it not getting disabled
Solution 1:[1]
ok, really you should be using prop instead of attr for recent implementations of jQuery
$(".grid-prev-btn").addClass('ui-state-disabled').prop('disabled', true);
attr would be more applicable to the written disabled="disabled" attribute on a tag, so should more correctly be .attr("disabled", "disabled")
However, disabled on hyperlinks isn't supported on modern browsers, so I'd suggest the following. The .attr, disabling pointer-events and adding a click handler for should the link be triggered by the keyboard
As you are using jQuery 1.8.x, I would recommend the full solution as follows.
$(".grid-prev-btn").addClass('ui-state-disabled').attr('disabled', 'disabled').css('pointer-events', 'none').on("click", function() { return false; });
You could of course remove the pointer-events bit from inline, and put it in your CSS for .ui-state-disabled
a.ui-state-disabled { pointer-events: none; }
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
