JavaScript
- 1 ответ
- 0 вопросов
1
Вклад в тег
const platformButtons = document.querySelectorAll(".changer__platform");
const activeTargetClass = "platform__description_active";
platformButtons.forEach(tab => tab.addEventListener("click", () => {
const target = document.querySelector(`#${tab.id}_desc`);
const currentTarget = document.querySelector(`.${activeTargetClass}`);
currentTarget && currentTarget.classList.remove(activeTargetClass);
target && target.classList.add(activeTargetClass);
}));
const platformButtons = document.querySelectorAll(".changer__platform");
const activeTargetClass = "platform__description_active";
platformButtons.forEach(tab => tab.addEventListener("click", () => {
document.querySelector(`.${activeTargetClass}`)?.classList.remove(activeTargetClass);
document.querySelector(`#${tab.id}_desc`)?.classList.add(activeTargetClass);
}));