0
I have the following HTML structure:
<div class="slider">
<div class="slide fade ativa"> <img src="_img/_banner/_site/bg_1.jpg" /> <span>Este é 1</span> </div>
<div class="slide fade"> <img src="_img/_banner/_site/bg_2.jpg" /> <span>Este é 2</span> </div>
<div class="slide fade"> <img src="_img/_banner/_site/bg_3.jpg" /> <span>Este é 3</span> </div>
<nav>
<button class="anterior">Anterior</button>
<button class="proximo">Próximo</button>
</nav>
</div>
I need to run inside the div.slider, all, and only, Divs.slide excluding the Buttons from the loop. How do I do?
The goal is to create a slide in which, when you arrive at the last div, resume the loop to the first div. The way I’m going down, it’s not working.
const blocos = $("div.slider div.slide");
function startslider() {
ativa = $("div.slider div.ativa")
if (!$(ativa).next().length) {
ativa = blocos.first()
}
$(ativa)
.removeClass("ativa")
.next()
.addClass("ativa")
setTimeout(startslider, 5000)
}
setTimeout(startslider, 5000)