JSFiddle - React, Tailwind, and code Playground

HTML

<div class="container">
    <div class="header"><span>Expand</span>

    </div>
    <div class="collapseDiv">
        <ul>
            <li>List 1</li>
            <li>List 2</li>
            <li>List 3</li>
           
        </ul>
    </div>
     <div class="header"><span>Expand</span>

    </div>
    <div class="collapseDiv">
        <ul>
            <li>List 1</li>
            <li>List 2</li>
            <li>List 3</li>
           
        </ul>
    </div>
    
</div>

CSS

.container {
    width:100%;
    border:1px solid #d3d3d3;
}
.container div {
    width:100%;
}
.container .header {
    background-color:#d3d3d3;
    padding: 2px;
    cursor: pointer;
    font-weight: bold;
}

JavaScript

$(".header").click(function () {

    $header = $(this);
    //getting the next element
    $content = $header.next();
    //open up the content needed - toggle the slide- if visible, slide up, if not slidedown.
    $content.slideToggle(500, function () {
        //execute this after slideToggle is done
        //change text of header based on visibility of content div
        $header.text(function () {
            //change text based on condition
            return $content.is(":visible");
        });
    });

});