Why do you need to get the actual hyperlink? If you just want to indicate what page you are on, use "li.selected a" as your CSS selector and it will find the proper link. I do this all the time for navigation lists.
Otherwise, you will have to have an id on the actual link, not the list element. This would of course work at well, but then you have to assign an id to you link in the navigation code. Not very clear I know, but maybe this helps... Keith Bingman Tel: +49-7731-79838380 [EMAIL PROTECTED] http://keithbingman.com On May 28, 2007, at 1:25 PM, Oliver Coningham wrote: > Hi - > > Thanks for the useful information about how to add JavaScript to a > page. > > I know it's not quite on the topic of RoR, but I need a little bit > of help with my JavaScript. > > My HTML is as follows: > <ul id="nav"> <li id="nav-welcome"><a href="http:// > www.spongenewmedia.co.uk/" title="Return to the home page">Welcome</ > a></li> <li id="nav-blog"><a href="/blog/" title="Read the > latest blog entries">Blog</a></li> <li id="nav-contact"><a > href="/contact/" title="Contact information for Oliver > Coningham">Contact</a></li></ul> > > What I want to do is apply the class "selected" to certain links > using JavaScript. The purpose of this is to show what page you are > currently on. > > The JavaScript I currently have is this: > > <script type="text/javascript"> document.getElementById('nav- > blog').className='selected'; </script> > > However, this only applies the class of "selected" to the <li> > item. How to use the getElementById function to select the actual > hyperlink? > > Many thanks in advance! > > _________________________________________________________________ > Try Live.com: where your online world comes together - with news, > sports, weather, and much more. > http://www.live.com/getstarted > _______________________________________________ > Radiant mailing list > Post: [email protected] > Search: http://radiantcms.org/mailing-list/search/ > Site: http://lists.radiantcms.org/mailman/listinfo/radiant _______________________________________________ Radiant mailing list Post: [email protected] Search: http://radiantcms.org/mailing-list/search/ Site: http://lists.radiantcms.org/mailman/listinfo/radiant
