Reputation:
I am using this code to set and remove the disabled attribute on buttons on my web page:
if (localStorage.buttonColor) {
document.getElementsByTagName('html')[0].className = localStorage.buttonColor;
var themeButtons = document.querySelectorAll(".theme");
for (var button in themeButtons) {
themeButtons[button].removeAttribute("disabled");
}
document.querySelector('button[name="' + localStorage.buttonColor + '"]').disabled = true;
}
But it's giving me a message saying:
Uncaught TypeError: Object 0 has no method 'removeAttribute'
Can someone give me advice on this?
Upvotes: 0
Views: 54
Reputation: 253485
Treat disabled
as a property, not an attribute:
themeButtons[button].disabled = false;
Upvotes: 3