Hi
I have an automated carousel that shows different testimonials automatically. I have some indicators below that change color with the corresponding information. What I would like to do is click on the indicator and show the relevant information without stopping/disrupting the automated carousel. Does anyone know how this can be done? I’ve tried using the change image function onclick within the HTML, but this seems to screw up the carousel completely.
This is my JS
var slideIndex = 0;
carousel();
function carousel() {
var x = document.querySelectorAll(".profiles article");
var y = document.querySelectorAll(".indicators div");
for (i = 0; i < x.length; i++) {
y[i].classList.remove("active");
x[i].classList.remove("profile-active");
}
slideIndex++;
if (slideIndex > x.length) {slideIndex = 1}
x[slideIndex-1].classList.add("profile-active");
y[slideIndex-1].classList.add("active");
setTimeout(carousel, 4000);
}
function changeImage(){
slideIndex = 0;
carousel();
};
HTML
<section id="testimonials" class="style bg-off-white pd-bottom">
<h2 class="title pd-top txt-white">Testimonials</h2>
<section class="profiles">
<article class="profile-active">
<img src="public/images/profile-1.jpg" alt="Profile pic of Jane Doe">
<p class="text-style">
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Quasi, repellendus in tempore expedita accusantium assumenda
minus quaerat perferendis placeat veniam nostrum unde odio incidunt nisi?</p>
<p class="text-style"><span>Jane Doe</span>, CEO, company.</p>
</article>
<article>
<img src="public/images/profile-2.jpg" alt="Profile pic of John Doe">
<p class="text-style">
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Quasi, expedita accusantium assumenda veniam nostrum unde odio incidunt
nisi?</p>
<p class="text-style"><span>John Doe</span>, CEO, company.</p>
</article>
<article>
<img src="public/images/profile-3.jpg" alt="Profile pic of Jack Doe">
<p class="text-style">
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Blanditiis reprehenderit totam nemo quo. Itaque, repudiandae. Assumenda sit vitae veniam? Numquam iste culpa maiores.
Excepturi, alias quae et perferendis voluptatem inventore.</p>
<p class="text-style"><span>Jack Doe</span>, CEO, company.</p>
</article>
</section>
<section class="indicators">
<div></div>
<div></div>
<div></div>
</section>
</section>
Website in Question