>From the sample markup with the highlight classes, it looks like the
OP wants to highlight anchors in the LI tags that are in direct line
to the final anchor. In that case, just adding the class to all the
anchors in each parent UL won't work. If you filter the results you
can achieve what your sample code indicates:

$('a').hover(function(){
        var _this = this;
        $(this).parents('li').find('a').filter(function(){
                return $.inArray(_this,$(this).parent().find('a'))+1;
        }).addClass('highlight');
},function(){
        $(this).parents('li').find('a').removeClass('highlight');
});

On Apr 23, 2:51 pm, Ricardo <ricardob...@gmail.com> wrote:
> Assuming the base UL or any of it's parents are contained in another
> UL (which would mess this up):
>
> $(this).parents('ul').find('a').addClass('highlight');
>
> On Apr 23, 5:00 pm, paulinstl <paulsha...@gmail.com> wrote:
>
> > Request: I want to highlight every "<A>" within the parents of an
> > object up to the base element of "<UL>"
>
> > For example, this original code:
> > <ul>
> >   <li><a href="/">link</a></li>
> >   <li><a href="/">link</a>
> >     <ul>
> >       <li><a href="/">link</a></li>
> >       <li><a href="/">link</a>
> >         <ul>
> >           <li><a href="/">link</a>
> >             <ul>
> >               <li><a href="/">HOVER OVER THIS</a></li>
> >             </ul>
> >           </li>
> >           <li><a href="/">link</a></li>
> >         </ul>
> >       </li>
> >       <li><a href="/">link</a></li>
> >     </ul>
> >   </li>
> >   <li><a href="/">link</a></li>
> > </ul>
>
> > Should appear like so (assuming an addclass method):
>
> > <ul>
> >   <li><a href="/">link</a></li>
> >   <li><a href="/" class="highlight">link</a>
> >     <ul>
> >       <li><a href="/">link</a></li>
> >       <li><a href="/" class="highlight">link</a>
> >         <ul>
> >           <li><a href="/" class="highlight">link</a>
> >             <ul>
> >               <li><a href="/" class="highlight">HOVER OVER THIS</a></
> > li>
> >             </ul>
> >           </li>
> >           <li><a href="/">link</a></li>
> >         </ul>
> >       </li>
> >       <li><a href="/">link</a></li>
> >     </ul>
> >   </li>
> >   <li><a href="/">link</a></li>
> > </ul>
>
> > I'm at a loss and I'm tired.  Can you help a brother out?  Basically
> > the best path from A to Z
>
> > Thanks for glancing at this.
>
> > paul

Reply via email to