JSFiddle - React, Tailwind, and code Playground
by sfoster
HTML
<div id="show-hide-thing">
Some text that should show/hide
</div>
<button id="toggler">
Toggle
</button>
JavaScript
$(document).ready(function(){
$("#toggler").click(function(){
// be careful, if you show a hidden element, then query for
// showing elements to hide, you'll hide the thing just showed!
let visibleNodes = $("#show-hide-thing:visible");
let hiddenNodes = $("div:hidden");
visibleNodes.hide();
hiddenNodes.show();
});
});