divnode = parent.childNodes[i]; if(typeof divnode == 'undefined'){ alert('undefined'); } else{ alert('nicht undef'); divnode.style.display = "none"; }