Question:
I have built a simple carousel which fades in/out of various images. The visual changes happen in CSS when JS changes the class.This worked perfectly with two slides. Now I’ve introduced a third it does not and I can now see why it worked with 2 and doesn’t with 3 or more.
Essentially what I’d like to achieve is this:
Every 7 seconds the script removes all instances of
slide--active
and adds it to the next item in the loop.I’m using Jquery throughout the site, so it makes sense to utilise it. The CSS below can be ignored, I’m only interested in the class change.
Answer:
You can do it like this:Demo
If you have better answer, please add a comment about this, thank you!