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");}
if (document.getElementById(" ") == curSlide) { e.target.classList.add("text__show");} else { e.target.classlist.add("text__hidden");}