var disableSelection = function(){ $("#elementId").attr("disabled","disabled"); }; var enableSelection = function(){ $("#elementId").removeAttr("disabled"); };
I have following requirements:
Adding attribute "disabled" works well for IE. Yet, when I try to remove attribute by using jQuery revomeAttr() method then instead of removing attribute:
Use .prop
instead of .attr
to affect an element's disabled state:
var disableSelection = function(){ $("#elementId").prop("disabled", true); }; var enableSelection = function(){ $("#elementId").prop("disabled", false); };
For more information, see .prop() vs .attr().
You can use removeProp('disabled')
instead. It worked for me while removeAttr('disabled')
didn't.
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