[thelist] Q on dHTML sibling/child
Jeff Howden
jeff at jeffhowden.com
Sat Mar 13 01:47:36 CST 2004
walter,
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: jsWalter
>
> I have this block...
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
first off, drop the dots in the html samples. how annoying to have to strip
those to test the code.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> <.li>
> <.span onclick="do_menu(this)" id='zz'>
> <.a href="#" Xtarget="display">About</a>
> </span>
> <.ul class="level_two">
> <.li class="active">
> <.a href="../index.html" target="display"
> >Board Members</a>
> </li>
> <.li>
> <.a href="../index.html" target="display"
> >NYSBA Staff</a>
> </li>
> <.li><a href="../index.html" target="display"
> >Members</a>
> </li>
> </ul>
> </li>
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
the <span> tags are superfluous. you could just as easily put the id
attribute and onclick event handler on the <a> tag. for that matter, since
the <a> tag doesn't actually *do* anything, you could put all that info on
the containing <li> tag. then, it's a simple matter of toggling the display
of the first childNode/childElement.
fwiw, i usually avoid dom-walking if at all possible. for similar
functionality, but executed in a different manner, check this out:
http://evolt.jeffhowden.com/jeff/code/toggle_display.cfm
.jeff
Jeff Howden - Web Application Specialist
Résumé - http://jeffhowden.com/about/resume/
Code Library - http://evolt.jeffhowden.com/jeff/code/
More information about the thelist
mailing list