hello,
can anyone help med check what I am missing in this code:
//here I want to make the lists unvisible when you enter the page.
function borja(){
var vanster=document.getElementsByTagName("h2");
for (i=0; i<vanster.length; i++)
{
vanster[i].nextSibling.nextSibling.className="osynlig";
}
}
function visa(){
var sibling=this.nextSibling.nextSibling;
sibling.className="synlig"; }
function dolj(){
var sibling=this.nextSibling.nextSibling;
sibling.className="osynlig"; }
function kolla(){
var list=document.getElementsByTagName("h2");
for (i=0; i<list.length; i++){
//this works, the list unfolds as I want it to if(list[i].nextSibling.nextSibling.className=="osynlig")
{
list[i].onclick=visa;
}
//here is doesnt work, the list should fold when I click the h2 again
else if(list[i].nextSibling.nextSibling.className=="synlig"){
list[i].onclick=dolj;
}
}
}
function init(){
borja();
kolla();
}
window.onload=init;
I am totally stuck and would appreciate the help:confused: