我想這HTML代碼:如何解決函數內部調用函數的元素?
<button name="darkBlue" onclick="setThemeColor(this.name)">Blue</button>
<button name="black" onclick="setThemeColor(this.name)">Black</button>
和腳本:
function setThemeColor(buttonName) {
localStorage.themeColor = buttonName;
document.getElementsByTagName('html')[0].className = buttonName
var themeButtons = document.querySelectorAll(".theme");
for (var button in themeButtons) {
themeButtons[button].disabled = false;
}
// this.disabled = false;
// element.setAttribute("disabled", "disabled");
}
我有一個問題就在這裏設置調用該功能按鈕的禁用狀態。有人能告訴我我該怎麼做。我嘗試了兩件事,但都沒有奏效。
@DavidThomas你在哪裏? – VisioN
'function setThemeColor(sender,buttonName)''>'setThemeColor(this,this.name)'。那麼你可以通過發件人,並在函數中獲得其名稱再次將其減少到一個參數 – DarkBee
@RGraham已經做 – DarkBee