2013-10-11 31 views
0

我使用這個代碼來設置和刪除按鈕禁用的屬性在我的網頁上:如何從我的頁面上的按鈕元素中刪除殘疾人?

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

款待disabled作爲一個屬性,而不是一個屬性:

themeButtons[button].disabled = false;