I can hide and show a div fine. The problem arises when I want it to hide other div that I opened before it.
var openDiv="";
function toggleDiv(divid){
if(document.getElementById(divid).style.display == 'none'){
if(openDiv != ""){
document.getElementById(openDiv).style.display = 'none';
}
document.getElementById(divid).style.display = 'block';
var openDiv = divid;
}else{
document.getElementById(divid).style.display = 'none';
}
}
There’s the code I am trying to get it to work but it just seems to break. Any help or tips would be much appreciated.