walking the DOM

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff Thies

    walking the DOM

    I'm unsure of an efficient way of doing this.

    I have nested lists that I want to collapse/expand:

    <ul>
    <li>find following nested list (ul) by using a reference to this node
    <ul>
    <li>...

    Doing this by looking through childNodes seems crazy. Isn't there a way to
    find the next node? A better way?

    Jeff




  • Matt Kruse

    #2
    Re: walking the DOM

    "Jeff Thies" <nospam@nospam. net> wrote:[color=blue]
    > I have nested lists that I want to collapse/expand:
    > <ul>
    > <li>find following nested list (ul) by using a reference to this node
    > <ul>
    > <li>...
    > Doing this by looking through childNodes seems crazy. Isn't there a way to
    > find the next node? A better way?[/color]

    Why does it seem crazy?

    By the way, if you're looking to turn <ul> lists into expandable/collapsable
    trees, you can use and/or look at my code which does exactly this:


    --
    Matt Kruse
    Javascript Toolbox: http://www.mattkruse.com/javascript/


    Comment

    • Jeff Thies

      #3
      Re: walking the DOM


      "Matt Kruse" <newsgroups@mat tkruse.com> wrote in message
      news:c6clh40j25 @news2.newsguy. com...[color=blue]
      > "Jeff Thies" <nospam@nospam. net> wrote:[color=green]
      > > I have nested lists that I want to collapse/expand:
      > > <ul>
      > > <li>find following nested list (ul) by using a reference to this node
      > > <ul>
      > > <li>...
      > > Doing this by looking through childNodes seems crazy. Isn't there a way[/color][/color]
      to[color=blue][color=green]
      > > find the next node? A better way?[/color]
      >
      > Why does it seem crazy?[/color]

      You're right. It wasn't that hard.
      [color=blue]
      >
      > By the way, if you're looking to turn <ul> lists into[/color]
      expandable/collapsable[color=blue]
      > trees, you can use and/or look at my code which does exactly this:
      > http://www.mattkruse.com/javascript/mktree/[/color]

      Pretty cool!

      What's the scrollIntoView do?

      My funky version (30 lines):



      Forgot how to change background images.

      Cheers,
      Jeff
      [color=blue]
      >
      > --
      > Matt Kruse
      > Javascript Toolbox: http://www.mattkruse.com/javascript/
      >
      >[/color]


      Comment

      Working...