How can I add that would click to change the text?

good day , how to do that would click-through to Read more.. text is changed to Hide?
<p class="hide_sub">Read more..</p>

const readMore = document.getElementsByClassName('hide_sub')[0];

let click = 0;
readMore.addEventListener('click', () => {

click++;
 if (click == 1) {
 document.getElementsByClassName('hide')[0].style.display = 'block';

 } else if (click == 2) {
 document.getElementsByClassName('hide')[0].style.display = 'none';


 click = 0;
}
});<code lang="html">

</code>
April 19th 20 at 12:06
2 answers
April 19th 20 at 12:08
Solution
const readMore = document.getElementsByClassName("hide_sub")[0];

readMore.addEventListener("click", () => {
 if (readMore.textContent === "Read more..") {
 readMore.textContent = "Hide";
 } else {
 readMore.textContent = "Read more..";
}
});
document.getElementsByClassName("hide_sub")[0];
document.querySelector(".hide_sub"); - crawford.Rosenbaum commented on April 19th 20 at 12:11
April 19th 20 at 12:10
Solution
const readMore = document.querySelector(".article__hide-sub");
readMore const__content = document.querySelector(".article__hide");
const activeClass = "active";

readMore.addEventListener("click", function (event) {
readMore__content.classList.toggle(activeClass);
readMore__content.style.setProperty(
"--height",
`${readMore__content.scrollHeight}px`
);

 event.target.textContent =
 event.target.textContent === "Read more..."
 ? (event.target.textContent = "Hide text")
 : (event.target.textContent = "Read more...");
});


Find more questions by tags JavaScript