Sebastian
KPCKevin Powell - Community
•Created by Sebastian on 1/18/2024 in #front-end
Unicode characters broken in Safari?
1 replies
KPCKevin Powell - Community
•Created by Sebastian on 4/13/2023 in #front-end
Class toggle when div ID == var
Hey front-enders!
I’ve been building a carousel with some snippets of JS and CSS, where 'var curSlide' returns the index of the current slide.
My next goal is to reveal different text elements inside of a div that is adjacent to the slider (so that they don’t follow the movement of the carousel.
Now I want to show/hide the text element, have assigned them with IDs that are identical to each slide index, and want to run an if-statement to send the correct css class to corresponding IDs.
I’ve kind of "sketched" it in my head, but my JS knowledge is more or less non-existent, so obviously it doesn’t work 🤣
Any pointers on how to do this is much appreciated!
if (document.getElementById(" ") == curSlide) {
e.target.classList.add("text__show");
} else {
e.target.classlist.add("text__hidden");
}
5 replies