[thelist] Navigating the DOM
Joe Ngo
chilijoe at gmail.com
Mon Apr 4 05:23:52 CDT 2005
Since you're already familiar with the CSS, try Simon Willison's
document.getElementsBySelector() function:
http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector
On Apr 4, 2005 12:13 PM, Noah St.Amand <noah at tookish.net> wrote:
> Hi,
>
> I'm trying to implement a drop-down menu script on a site built around a
> CMS. The CMS generates the menu, and so it doesn't have the hooks that I
> would typically use to make the drop-down script work.
>
> Is it possible to refer to an element that doesn't have an id? To be
> specific, given this HTML:
>
> <div id="shortcuts">
> <div class="block block-menu" id="block-menu-36">
> <h3>Shortcuts</h3>
> <div class="menu">
> <ul>
> <li class="expanded"><a href="residents" title="">Residents</a>
> <ul>
>
> Is there anyway to do this in the javascript:
>
> var menu = "the last ul in the example above"
> var actuator = "the a after <li class="expanded"> in the example above"
>
> I've tried a bunch of variations beginning with:
>
> document.getElementById("shortcuts").firstchild.
>
> Which I think gets me as far as the div with the id "block-menu-36", but
> I can't seem to get any further. I'd like to start from "shortcuts"
> because this is something I set in the template, rather than something
> generated by the CMS (so if it changes, it will be because I changed it).
>
> On a vaguely related note, can anyone recommend a good DOM scripting
> book for someone with a fair bit of server-side coding experience, but
> very little on the client side? I'm pretty fluent in CSS, but basically
> useless with Javascript (see exhibit A above). I would prefer
> something standards-oriented, and something that might help me get
> started using Ajax[1].
>
> Thanks for any help.
>
> Noah
>
> [1] <http://www.adaptivepath.com/publications/essays/archives/000385.php>
>
> --
>
> * * Please support the community that supports you. * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>
--
Take back the web!
http://www.spreadfirefox.com
More information about the thelist
mailing list