Javascript active image on slider

Hi there,

I have a problem with js slider.
Let’s say I have 3 images, on first image I have class=“active” which is styled with css:

.active {
    border: 2px solid #cca;

Next, there are two buttons next and prev, the idea is to when I click on next image or on previous image, active state will set on that image.
I can’t figure out how to work with this active state, I know I can’t do it with for loop, because then every displayed image will be active.

I stuck for couple of days on this one, so I need help, thanks!

The usual way to do this is to remove active from all related elements, and then to add active to only the one that needs it.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.