Answer the question
In order to leave comments, you need to log in
How to change color on click? and then remove?
<p class="car-fleet car-gazel-mobil" id="positionSlide" data-position="0" data-color="red">1</p>
<p class="car-fleet" id="positionSlide" data-position="1060" data-color="blue" >2</p>
<p class="car-fleet" id="positionSlide" data-position="2120" data-color="black">3</p>
document.querySelectorAll("#positionSlide").forEach((positionSlide) => {
positionSlide.addEventListener("click", function () {
sliderWidth.style.left = -this.dataset.position + "px"
this.classList.add ('color')
});
});
Answer the question
In order to leave comments, you need to log in
querySelectorAll("#positionSlide") does not seem to be a valid query, since the id must be unique on the page.
For the rest, add another change of border color to the function, first for everyone to non, and then for the current one to the desired border.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question