I'm trying to write short piece of code where I have a bunch of divs inside one big and I want a class called "focused" to first be put to the first div, then after 5 seconds toggle to next one, and so on. I'd also want this to be loopable.
Here's my HTML code:
<div class="rowwrapper">
<div class="flipcontainer">
<div class="card focused">
Content
</div>
</div>
<div class="flipcontainer">
<div class="card">
Content
</div>
</div>
<div class="flipcontainer">
<div class="card">
Content
</div>
</div>
etc…
</div>
I started with a JS code by myself, but it doesn't seem to cooperate with me.
$(function() {
setInterval(function() {
$(".rowwrapper").next(".card").toggleClass("focused");
}, 5000)
});