JSFiddle - React, Tailwind, and code Playground

by Rich Costello

HTML

<script>
    
    function toggle(){
if(document.getElementById("MyId").className == "hide")
   document.getElementById("MyId").className = "show";
else
   document.getElementById("MyId").className = "hide";
}

    
</script>
<a href="#" id="togglebutton" onclick="toggle()">Show/hide</a>

<div id="MyId" class="show"> 
   I want this div to toggle between the 'show' class and the 'hide' class
</div>

CSS

.show {
    display: block;
}


.hide {
    display: none;
}