Tippfehler bei Funktionsname:
KLAPPT:
function switchdiv(theid){
var thearray= new Array("cxx","cyy", "czz");
for(i=0; i<thearray.length; i++){
if(thearray[i] == theid){
document.getElementById(theid).style.visibility ="visible";
}
else{
document.getElementById(thearray[i]).style.visibility ="hidden";
}
}
}
<div id="cxy"><a onclick="switchdiv('cxx');" >Test</a></div>
<div id="cyx"><a onclick="switchdiv('cxx');" >Test2</a></div>
KLAPPT NICHT: (es passiert gar nichts mehr)
-------------
function switchdiv(theid,theid2){
var thearray= new Array("cxx","cyy", "czz");
for(i=0; i<thearray.length; i++){
if(thearray[i] == theid){
document.getElementById(theid).style.visibility ="visible";
}
if(thearray[i] == theid2){
document.getElementById(theid2).style.visibility ="visible";
}
else{
document.getElementById(thearray[i]).style.visibility ="hidden";
}
}
}
<div id="cxy"><a onclick="switchdiv('cxx','');" >Test</a></div>
<div id="cyx"><a onclick="switchdiv('cyy','czz');" >Test2</a></div>