Я создаю игру-головоломку, в которой пользователь с помощью щелчков мыши перемещает «ячейки» или числа в правильном порядке.
Все шло нормально, пока я не решил добавить блок кода, позволяющий пользователю менять тему игры (цвета, шрифты).
Теперь щелчки мыши не регистрируются.
Есть ли что-то, что мне не хватает или что мне следует изменить?
Ниже добавлен код для переключения темы.
Для самой игры также есть таблица и класс «ячейка».
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 : ""))
);
Подробнее здесь: https://stackoverflow.com/questions/798 ... -dont-work