[thelist] operating on DOM Nodes (collapsible tree)

Kae Verens kverens at contactjuggling.org
Thu Feb 20 04:23:20 CST 2003


Aleem Bawany wrote:
> I am trying to implement a collapsable tree:
>
> <ul>
>  <li> one </li>
>  <ul>
>   <li> two </li>
>  </ul>
> </ul>
>
> so clicking on list item one should toggle the 'display'
> property of the second list. I looked up the 'node'
> interface [1] and nextSibling seems to fit the bill,
> so I can create a javascript without having to explicitly
> tie an event listen on each object but through one script.
>
> I can't seem to do much with the node interface. I want
> something like:
>
> this.nextSibling.style.display = 'none';

I have something like that working on the left navigation menu of
http://contactjuggling.org/

you may have to hack this:

the code:
function fm(a){
  if(!a)return;
  o=a.parentNode.childNodes.item(4);
  o.style.display=(o.style.display=='none')?'block':'none';
  p=a.parentNode.childNodes.item(2);
  p.innerHTML=(o.style.display=='none')?'+':'-';
}

--
Kae Verens               _______\_   webworks.ie
work: www.webworks.ie       _____\\__   webhosts
play: www.contactjuggling.org  ___\\\___  design
kae:  kverens.contactjuggling.org _\\\\____ code




More information about the thelist mailing list