Files
Figma_2/main.js
2025-10-22 01:19:44 +03:00

57 lines
2.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// -----------------------------------------HEADER-----------------------------------------------------------
document.querySelectorAll('.header_top_item').forEach((item) => {
item.addEventListener('click', (e) => {
e.preventDefault(); // если не нужно переходить со страницы
document.querySelectorAll('.header_top_item').forEach(el => el.classList.remove('active'));
item.classList.add('active');
});
});
// -------------------------------ACCORDION-SLIDER-----------------------------------------------------------
const items = document.querySelectorAll('.accordion-item');
// Делаем первый аккордеон активным по умолчанию
if(items.length > 0) {
items[0].classList.add('active');
}
// items.forEach(item => {
// item.addEventListener('click', () => {
// items.forEach(i => i.classList.remove('active'));
// item.classList.add('active');
// });
// });
// код ниже если нужно картинку на открытую и закрытую колонку(ток классы добавь в html и картинки по 2 или че там придумаешь)
items.forEach(item => {
item.addEventListener('click', () => {
items.forEach(i => {
i.classList.remove('active');
i.querySelector('.img-open').style.display = 'none';
i.querySelector('.img-closed').style.display = 'block';
});
item.classList.add('active');
item.querySelector('.img-open').style.display = 'block';
item.querySelector('.img-closed').style.display = 'none';
});
});
// -----------------------------------------ACCORDION-SECOND----------------------------------------------
document.addEventListener('DOMContentLoaded', () => {
const cards = document.querySelectorAll('.advantage_slider_item');
cards.forEach(card => {
card.addEventListener('click', () => {
// если уже активна — просто закрываем
if (card.classList.contains('active')) {
card.classList.remove('active');
} else {
// иначе закрываем все остальные и открываем текущую
cards.forEach(c => c.classList.remove('active'));
card.classList.add('active');
}
});
});
});