either you assign a class which is invisible or you add a new style to a existing class.
Usually its not a good idea to redefine css classes due side effects. For the sake of showing you something new i use the visibility css rule. Display : "none" would do the same.
This new class i would add either hard coded in the css or by js.
.cormes_invisible{visibility:hidden;}
Now all you has to do is to simply change the class name.
I add "_invisible" so its rather trivial to restore the original class later one by using the split function. So there is nothing complicated or strange in it :)
function makeinvisible(id){
var element=document.getElementById(id)
try { // rather brutal way
element.classList.remove("cormes");
} catch (ex){}
element.classList.add("cormes_invisible");
}
function makevisible(id){
var element=document.getElementById(id)
try { // rather brutal way
element.classList.remove("cormes_invisible");
} catch (ex){}
element.classList.add("cormes");
}
another way would be to add a style attribute with the invisible css. and remove it afterwards. There are a few posiibilitys. (And alot of very nice tutorials in the web ;))
btw: the other classic way would be :
var elements =document.getElementsByClassName("cormes");
for (i=0;i<elements.length;i++){
try { // rather brutal way
elements[i].classList.remove("cormes");
} catch (ex){}
elements[i].classList.add("cormes_invisible");
}