Slider/Carrosel with JS

Asked

Viewed 6 times

0

I’m trying to make a data carousel that are coming from a mysql database, I’m trying to put 4 Divs at the beginning to go through with the carousel, but it only shows one, follows the js code

<script>
    var slideIndex = 1;
    showSlides(slideIndex);

    function plusSlides(n) {
    showSlides(slideIndex += n);
    }

    function showSlides(n) {
    var i;
    var slides = document.getElementsByClassName("show");
    if (n > slides.length) {slideIndex = 1}
    if (n < 1) {slideIndex = slides.length}
    for (i = 0; i < slides.length; i++) {
        slides[i].style.display = "none";
    }
    slides[slideIndex-1].style.display = "block";
    }
</script>
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.