S
S
SergeyVladimirovich93932019-10-19 09:10:55
JavaScript
SergeyVladimirovich9393, 2019-10-19 09:10:55

How to make slider autoscroll by class?

How can I auto-scroll a slider? Because the slider is made on html + css, then you need to add auto-scroll every 4 seconds. Is it possible to add a function to the next class using JS? The slider has the following code:

<ul class="slides">
 <input type="radio" name="radio-btn" id="img-1" checked="">
    <li class="slide-container">
    <div class="slide">
 <a href="ссылка"><img src="ссылка на баннер"></a>
    </div>
    <div class="nav">
 <label for="img-7" class="prev"></label> <label for="img-2" class="next"></label>
    </div>
 </li>
</ul>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pashenka, 2019-10-19
@like-a-boss

If it’s completely calic, then you can do something like this:

setInterval(function() {
  document.getElementsByClassName('next')[0].click();
  var slide1 = document.getElementsByClassName('slide-container')[0],
    slidesContainer = document.getElementsByClassName('slides')[0];
  
  slidesContainer.appendChild(slide1);
}, 4000);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question