Все шло нормально, пока я не решил добавить блок кода, позволяющий пользователю менять тему игры (цвета, шрифты).
Теперь щелчки мыши не регистрируются.
Есть ли что-то, что мне не хватает или что мне следует изменить?
Ниже добавлен код для переключения темы.
Для самой игры также есть таблица и класс «ячейка».
Код: Выделить всё
const themes = [{
name:"og",
}, {
name: "moonlight",
}, {
name: "purple",
}, {
name: "chocolate",
}];
const button = document.getElementById("theme-switcher-button");
const themeDropdownMenu = document.getElementById("theme-dropdown");
document.body.classList.add("theme-og");
button.addEventListener("click", () => {
themeDropdownMenu.hidden ? (themeDropdownMenu.hidden = false, button.setAttribute("aria-expanded", "true")) : (themeDropdownMenu.hidden = true, button.setAttribute("aria-expanded", "false"));
});
themeDropdownMenu.addEventListener("click", e => {
document.body.classList.remove(...document.body.classList);
document.body.classList.toggle(e.target.id);
themeDropdownMenu.hidden = true;
});
document.querySelectorAll('li[role="menu-item"]').forEach(
menu => menu.addEventListener("click", () => themes.forEach(theme => theme.name === menu.id.replace("theme-", "") ? document.getElementById("status").textContent = theme.message : ""))
);Код: Выделить всё
Switch Theme
[list]
[*]Original Green
[*]Moonlight
[*]Purple
[*]Chocolate
[/list]
Подробнее здесь: https://stackoverflow.com/questions/798 ... -dont-work
Мобильная версия