Reputation: 40454
How does one disable a button in internet explorer in pre ie9? I tried the following:
var button = document.getElementById('myButton');
if (button != 'undefined' && button != null)
button.disabled = true;
Upvotes: 1
Views: 65
Reputation: 4125
XML/HTML attribute values are strings, and thus the boolean values "true" and "false" won't be accepted; they have no special meaning
Try it with:
var button = document.getElementById('myButton');
if (button != 'undefined' && button != null)
button.disabled = 'disabled'; //'disabled' not false
This StackOverflow answer sums it up well, as to why you can't use booleans: https://stackoverflow.com/a/7089749/4206206
In SGML, an attribute may be minimized so that its value alone is short for both the name and the value, with the only possible value for the attribute in this case obviously being the attribute's own name. HTML uses this for boolean attributes, where the presence or absence of the attribute is what's meaningful, and its value is irrelevant.
Upvotes: 3