JSFiddle - React, Tailwind, and code Playground

HTML

<a class="showSingle" target="1">Div 1</a>

<a class="showSingle" target="2">Div 2</a>

<a class="showSingle" target="3">Div 3</a>

<a class="showSingle" target="4">Div 4</a>

<div id="div1" class="targetDiv">Lorum Ipsum1</div>
<div id="div2" class="targetDiv">Lorum Ipsum2</div>
<div id="div3" class="targetDiv">Lorum Ipsum3</div>
<div id="div4" class="targetDiv">Lorum Ipsum4</div>

CSS

.targetDiv {
    display: none
}

JavaScript

jQuery(function ($) {
    $('.showSingle').click(function () {
        var itemid = '#div' + $(this).attr('target'); //id of the element to show/hide.

        //Show the element if nothing is shown.
        if ($('.active').length === 0) {
            $(itemid).slideDown();
            $(itemid).addClass('active');

            //Hide the element if it is shown.
        } else if (itemid == "#" + $('.active').attr('id')) {
            $('.active').slideUp();
            $(itemid).removeClass('active');

            //Otherwise, switch out the current element for the next one sequentially.
        } else {
            $('.active').slideUp(function () {
                $(this).removeClass('active');
                if ($(".targetDiv:animated").length === 0) {
                    $(itemid).slideDown();
                    $(itemid).addClass('active');
                }
            });
        }
    });
});