Hi Oliver,

You have two typical options in this case.  The first is to give your  
<a> element an id, just like you did for the <li> element.  Then you  
could use that id in your javascript.  The other method, though, is  
probably what you want.  You could keep your html and javascript the  
way it is, and modify your css (I assume you're using css).  So  
instead of your css looking like

.selected {
     #some styles
}

you could have

.selected a {
     # some styles for hyperlink
}

This way your styling the hyperlink inside of an element with  
className "selected"

Hope that helps,
Matt

On May 28, 2007, at 7:23 AM, 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 waht 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 applys the class of "selected" to the <li> item.  
> How
> to use the getElementById function to select the actual hyperlink?
>
> Many thanks in advance!
>
>
>
> -- 
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> 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

Reply via email to