JavaScript
8
Вклад в тег
let count;
document.querySelectorAll(".slider__item").forEach((item) => {
item.addEventListener("click", (event) => {
const currentItem = event.target.closest(".slider__item");
count = currentItem.dataset.slickIndex; // Новая строка
currentItem.classList.toggle("opened");
removeClasses(currentItem);
});
});
document.addEventListener("keydown", (e) => {
if (count === undefined) return;
if (e.key === 'ArrowLeft') {
const currentSlide = document.querySelector(`[data-slick-index='${count}']`);
const nextSlide = document.querySelector(`[data-slick-index='${+count - 1}']`);
currentSlide.classList.remove("opened");
nextSlide.classList.add('opened')
count--;
} else if (e.key === 'ArrowRight') {
const currentSlide = document.querySelector(`[data-slick-index='${count}']`);
const nextSlide = document.querySelector(`[data-slick-index='${+count + 1}']`);
currentSlide.classList.remove("opened");
nextSlide.classList.add('opened')
count++;
}
});
const setTotalUnit = () => {
const total = document.querySelector(".totelunit");
const units = document.querySelectorAll(".unit");
let sum = 0;
units.forEach(item => {
sum += +item.innerHTML;
})
total.innerHTML = sum;
}
<div class="container">
<nav>
<ul class="topmenu">
<li><a href="">Home</a></li>
<li><a href="">Shop</a></li>
<li><a href="" class="down">Blog</a>
<ul class="submenu">
<li><a href="">Category</a></li>
<li><a href="">Author</a></li>
<li><a href="">Archive</a></li>
<li><a href="">Tags</a></li>
</ul>
</li>
<li><a href="" class="down">Portfolio</a>
<ul class="submenu">
<li><a href="">Category</a></li>
<li><a href="">Author</a></li>
<li><a href="">Archive</a></li>
<li><a href="">Tags</a></li>
</ul>
</li>
<li><a href="">Contact</a></li>
</ul>
</nav>
</div>
const container = document.querySelector('.container');
container.insertAdjacentHTML('beforeend', `<div>ТУТ ВАШ СПИСОК</div>`)