Set and clear active class

2019-08-30 08:23发布

问题:

I have a setInterval function that adds an active class to each item as it loops through, the problem i am having is firstly setting the initial active class on the first item and also clearing the active class from the previous item, see my codepen below

https://codepen.io/flashvenom/pen/WNeoRJd

I believe the are the offending lines

Overall i want only the active slide to have the class "ges--activ" at any one time

//BROKE add initial active class to first slide
firstActive.classList.add("ges--activ");

// BROKE - remove active class from slides
geSlider__ul.querySelector(".geSlider__li").classList.remove("ges--activ");