Skip to content
Advertisement

classList.remove[“active”] isn’t working as I expected

I’m trying to make a map gallery which consist in show 3 diferent locations using two buttons (previous and next). I added functionality to the next button but when I click on next, the map doesn’t move and it stays. For the first map that I wanted to show, I added “active” to the classes. I’m pretty lost right now, any suggestion or advice will be very appreciated.

Javascript

JavaScript

CSS

JavaScript

HTML

JavaScript

Advertisement

Answer

DOMTokenList.remove is a method. So, you need to call it with () instead of []. This is the same with .add().

mapGallery[currentlySelected].classList.remove("active"); mapGallery[currentlySelected].classList.add("active");

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement