JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<span id="dots">...</span>
<span id="more">Example Text</span>
<div class="btn-container">
<button id="my-btn">Lyrics</button>
</div>
</div>
CSS
.container {
text-align: center;
}
#more {
display: none;
color: black;
}
.btn-container {
margin-top: 10px;
text-align: center
}
#my-btn {
color: white;
background-color: black;
}
JavaScript
var dots = document.getElementById("dots")
var more = document.getElementById("more")
var btn = document.getElementById("my-btn")
btn.addEventListener("click", myFunction)
function myFunction() {
if (dots.style.display === "none") {
dots.style.display = "inline"
btn.innerHTML = "Lyrics"
more.style.display = "none"
} else {
dots.style.display = "none"
btn.innerHTML = "Read less"
more.style.display = "inline"
}
}