Ok, I have another question that's related to the first.

I need to highlight *only* the top-parent item (the same one I just
ran 'return false;' on) with the class 'nav-selected'.

This is the code that's being generated by the CMS I'm working with
when I click on Link 3a:

<ul>
    <li class="nav-path-selected"><a href="#">Link 1</a></li>
    <li><a href="#">Link 2</a></li>
    <li class="nav-path-selected"><a href="#">Link 3</a>
        <ul>
            <li><a href="#" class="nav-selected">Link 3a</a></li>
            <li><a href="#">Link 3b</a></li>
            <li><a href="#">Link 3c</a></li>
        </ul>
    </li>
    <li><a href="#">Link 4</a></li>
</ul>

I've got this:

if($("#nav li:first").hasClass("nav-path-selected").siblings("a"))
      // Add nav-selected class to parent li with children
      $(".nav-path-selected").addClass("nav-selected");
};

But it's not working for me. I'm *only* trying to affect the parent
<li> of the list that has a child <a> active in it.

Do you know how I can do that? Thanks for all your help so far, really
is appreciated.

osu



On Sep 24, 8:18 pm, osu <onesiz...@googlemail.com> wrote:
> That's perfect, thanks for that - the second example works a treat.
>
> osu
>
> On Sep 24, 7:10 pm, Andi23 <dowhatyouw...@gmail.com> wrote:
>
> > In that case, you can just remove the href attribute of the link(s):
> > $("li ul").siblings("a").removeAttr("href");
>
> > or, if you want to leave in the href attribute for future use?, you
> > can do this:
> > $("li ul").siblings("a").click(function(){
> >     return false;
>
> > });
>
> > good luck-

Reply via email to