I have a problem with the read more buttons under my testimonials on the page.
The left button is working correctly, but the right button is displaying text from the wrong testimonial.
I'm not sure why this is happening as there are no console errors.
You can see the issue by visiting clientsforcounsellors.com and scrolling down to view the testimonials.
Here is the code for the left testimonial:
<!-- Quotation -->
<p class="test-paragraph dark-grey-text mt-4"><i class="fas fa-quote-left pr-2"></i>"Harrison has been continually knowledgeable, patient, professional, and overall a fantastic help. He is clearly well informed in the digital marketing and web design field.<span class="dots">...</span><span class="read-more"> He always gives timely responses which are clear and helpful. The finished site looks professional and inviting – just what I wanted. I will recommend him to my colleagues. Thanks again, Harri."</span></p>
<button onclick="readMore()" class="read-more-btn">Read More</button>
And here is the code for the right testimonial:
<p class="test-paragraph dark-grey-text mt-4"><i class="fas fa-quote-left pr-2"></i>"Harrison has been continually knowledgeable, patient, professional, and overall a fantastic help. He is clearly well informed in the digital marketing and web design field.<span class="dots">...</span><span class="read-more"> He always gives timely responses which are clear and helpful. The finished site looks professional and inviting – just what I wanted. I will recommend him to my colleagues. Thanks again, Harri."</span></p>
<button onclick="readMore()" class="read-more-btn">Read More</button>
.read-more {
display: none;
}
<script>
var testParagraph = document.querySelectorAll(".test-paragraph");
var i;
for (i = 0; i < testParagraph.length; i++) {
function readMore() {
var dots = document.querySelector(".dots");
var moreText = document.querySelector(".read-more");
var btnText = document.querySelector(".read-more-btn");
if (dots.style.display === "none") {
dots.style.display = "inline";
btnText.innerHTML = "Read More";
moreText.style.display = "none";
} else {
dots.style.display = "none";
btnText.innerHTML = "Read Less";
moreText.style.display = "inline";
}
}
}
</script>