JSFiddle - React, Tailwind, and code Playground

HTML

<div id="first">first</div>
<div id="second">second</div>
<button onclick="hideAndShow()">Press me</button>

CSS

#second {
    display: block;
}

JavaScript

function hideAndShow() {
    var first = document.getElementById('first');
    var second =document.getElementById('second');
    if (first.style.display == "none") {
        first.style.display = "block";
        second.style.display = "none";
    }
    else {
        first.style.display = "none";
        second.style.display = "block";
    }
}