JSFiddle - React, Tailwind, and code Playground

by droplly

HTML

<div id="textArea" style="max-height: 100px;overflow:hidden;">
    <p >"Here is some text that I want added to the HTML file"</p>
    <p>
    "Here is some text that I want added to the HTML file"
    </p>
    <p>
    "Here is some text that I want added to the HTML file"
    </p>
    <p>
    "Here is some text that I want added to the HTML file"
    </p>
 <p>
 "Here is some text that I want added to the HTML file"
 </p>   
</div>


<a id="toggleButton" onclick="toggleText();" href="javascript:void(0);">See More</a>

JavaScript

let status = "less";
const textBox = document.getElementById("textArea");

function toggleText()
{
    
    if (status == "less") {
        textBox.style.maxHeight = "100%";
        document.getElementById("toggleButton").innerText = "See Less";
        status = "more";
    } else if (status == "more") {
        textBox.style.maxHeight = "100px";
        document.getElementById("toggleButton").innerText = "See More";
        status = "less"
    }
}