[thelist] javascript for expand/collapse list (aka tree view)

Sarah poohbear at designshift.com
Mon Sep 15 12:03:42 CDT 2003


> > I am looking for some JavaScript for an expandable/collapsible "tree view"
> > list (i.e. an unordered list in HTML). It only needs to work in Internet
> > Explorer 6 and Netscape 6+/Mozilla, as it is for a limited number of
>people
> > who all have similar computers. I have a general idea of how this would be
> > done with JavaScript using the onclick of each <li> and using childNodes
> > and parentNodes to do the hiding/showing of the list; I just don't want to
> > spend a whole lot of time trying to "re-invent the wheel". Basically, I
> > just want to make my client happy by adding this functionality to their
> > site, so I'm looking for a quick and dirty solution - but with nice clean
> > code :) So if anyone knows of an existing script which does something like
> > this, could you please point me to it?

I think when I originally sent this request, I should have been more clear 
that I wasn't actually trying to implement a navigation menu. What I have 
is a hierarchical list of categories from the site I'm working on, and each 
list item has a checkbox used to indicate that an administrator has 
permission to modify the category. But a recent message to thelist pointed 
to this script which, modified to work on <ul>s instead of <div>s, worked 
perfectly for me:
http://www.pixelmech.com/review/dom_tree_new.html
It is a very elegant solution, exactly what I was hoping for.

Many thanks to all who sent suggestions to my original question, and to Tom 
Dell'Aringa for the script I ended up using!

Sarah



More information about the thelist mailing list