I'm a beginner in the world of JavaScript. I have been working on customizing the "show more" button and encountered an issue. I managed to add text and a down arrow below the button, but when I click it, another button labeled "I don't know how to style it" appears with hidden content. Then, upon clicking again, the original show more button reappears without any icon or styling.
function toggleText() {
var showMoreText = document.getElementById("more");
var buttonText = document.getElementById("moreButton");
if (startpoint.style.display === "none") {
showMoreText.style.display = "none";
startpoint.style.display = "inline";
buttonText.innerHTML = "Show More";
} else {
showMoreText.style.display = "inline";
startpoint.style.display = "none";
buttonText.innerHTML = "Show Less";
}
}
.pink {
color: #FF7B5F;
}
#more {
display: none;
}
#moreButton {
background-color: transparent;
border-color: transparent;
}
<span id="startpoint"></span>
<span id="more">
<div class="clients BRANDING col-6 col-md-4 col-lg-3 col-lg-3">
<a href="#">
<figure class="filter-container">
<img class="img-fluid brand-img" src="./images/filter/logo" alt="Logo">
<figcaption class="product-desc"><p>text</p></figcaption>
<figcaption class="product-desc2"><h4>text</h4></figcaption>
</figure>
</a>
</div>
</span>
<button onclick="toggleText()" id="moreButton">
<p class="pink">Show More</p>
<img class="more" src="./images/downarrow" alt="arrow">
</button>