Untitled
unknown
plain_text
4 years ago
921 B
4
Indexable
const $ = document.querySelector.bind(document); const $$ = document.querySelectorAll.bind(document); // Xử lý tại Silder // 1. Chữ hiện lên từ từ const items = $$('.carousel-item'); const nextBtn = $('.carousel-control-next'); const prevBtn = $('.carousel-control-prev'); const cricle = $$('.rounded-circle'); var currentIndex = 1; nextBtn.onclick = function() { currentIndex = currentIndex < items.length - 1 ? ++currentIndex : 0; console.log(currentIndex); } prevBtn.onclick = function() { currentIndex = currentIndex > 0 ? --currentIndex : items.length - 1; console.log(currentIndex); } nextBtn.onmouseover = function() { cricle[1].style.backgroundImage = `url(assets/image/Slider/slider_${currentIndex + 1}.jpg)`; } prevBtn.onmouseover = function() { cricle[0].style.backgroundImage = `url(assets/image/Slider/slider_${currentIndex - 1}.jpg)`; }
Editor is loading...