我正在使用此代码来设置和删除我网页上按钮的 disabled 属性:
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;
}
但它给了我一条信息:
Uncaught TypeError: Object 0 has no method 'removeAttribute'
有人可以给我建议吗?