私は次のHTMLを持っています:
<button class="Blue" id="theme" onclick="setThemeColor(this)">#</button>
そして、次の機能:
function setThemeColor(button) {
localStorage.themeColor = // I need to set it here but I am not sure how
// if the class is Blue it needs to be Black
// if the class is Black it needs to be Blue
document.getElementsByTagName('html')[0].className = //
// I need to change the button class
}
どうすればそうすることができますか:
- ボタン クラスが Blue の場合、クリックするとクラスが Black に変更され、html クラス名が Blue に変更されます。
- ボタン クラスが Black の場合、クリックするとクラスが Blue に変更され、html クラス名が Black に変更されます。