اسلایدر تصویر با استفاده از html css و کدگذاری جاوا اسکریپت https://www.instagram.com/webstreet_code/ – انجمن DEV

Summarize this content to 400 words in Persian Lang
Image Background Selector
{
thumbnails.forEach((thumb, i) => {
thumb.classList.toggle(‘active-thumbnail’, i === index);
});
background.style.backgroundImage = `url(${thumbnails[index].getAttribute(‘data-bg’)})`;
};
// Left arrow click event
document.getElementById(‘left’).onclick = () => {
currentIndex = (currentIndex – 1 + thumbnails.length) % thumbnails.length;
updateBackground(currentIndex);
};
// Right arrow click event
document.getElementById(‘right’).onclick = () => {
currentIndex = (currentIndex + 1) % thumbnails.length;
updateBackground(currentIndex);
};
// Thumbnail click event to update the background
thumbnails.forEach((thumb, i) => {
thumb.onclick = () => {
currentIndex = i;
updateBackground(i);
};
});
// Set initial background
updateBackground(currentIndex);
]]>
وارد حالت تمام صفحه شوید
از حالت تمام صفحه خارج شوید
Image Background Selector