JSFiddle - React, Tailwind, and code Playground
HTML
<input type="button" onclick="javascript:toggle()" value="Toggle visibility">
<div id="showhide" style="display: block">
This text can be shown or hidden
</div>
JavaScript
window.toggle = function() {
// get the Div
var myDiv = document.getElementById('showhide');
// now toggle the visibility, depending on current state
if (myDiv.style.display == 'block') {
// Div is visible. hide it
myDiv.style.display = 'none';
} else {
// Div is hidden. show it
myDiv.style.display = 'block';
}
}