0

我正在使用此代码来设置和删除我网页上按钮的 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'

有人可以给我建议吗?

4

1 回答 1

3

视为disabled属性,而不是属性:

themeButtons[button].disabled = false;
于 2013-10-11T10:36:19.697 回答