What i want to do is to change the class of the div tag with a toggle button using javascript. So that when i press the button once the div tag gets the show class, and when i press the same button again it gets the hide class. Is this possible?
html:
<a id="togglebutton">Show/hide</a>
<div class="show"> 
   I want this div to toggle between the 'show' class and the 'hide' class
</div>
css:
.show {
    display: block;
}
.hide {
    display: none;
}
js:
function toggle(){
    var hide = document.querySelector(".hide");
    var show = document.querySelector(".show");
}
var hidebutton = document.querySelector(".togglebutton");
hidebutton.onclick = toggle
Would document.getElementById("MyId").className = "MyClass"; be usable somehow?
 
     
     
     
     
    