testes/js/Serviços/carrosel.js

10 lines
351 B
JavaScript

const carousel = document.querySelector(".carousel");
const arrowBtns = document.querySelectorAll(".weapper button");
const firstCardWidth = carousel.querySelector(".card").offsetWidth;
arrowBtns.forEach(btn => {
btn.addEventListener("click", () => {
carousel.scrollLeft += btn.id === "left" ? -firstCardWidth : firstCardWidth;
})
})