The trouble is you are using invalid markup. You can't put an UL
directly inside another UL. It can only contain list items, so you
need a structure like this:

<ul>
   <li>First-level/title</li>
   <li>
      <ul>
          <li>Submenu</li>
      </ul>
   </li>
<ul>

And then grab all the LIs that don't have a child ul:

$('#LHnav ul > li').filter(function(){
    return !$(this).children('ul').length;
});

Or a more pratical version:

<ul>
    <li>
       <span>About Us</span> <!-- or a header or whatever -->
       <ul>
           <li>History</li>
           <li>School Profile</li>
       </ul>
    </li>
    <li>
         ....
    </li>
<ul>

where you can get the first-level titles by simply using

$('#LHnav li > span') or $('#LHnav span')

does that help?

- ricardo

On Nov 30, 2:41 pm, flycast <[EMAIL PROTECTED]> wrote:
> No. I am definitely looking for the <li> sibling right before any
> <ul>...</ul>. I am building menus and submenus. Any <ul>...<ul> that
> appears below a <li>...</li> is a submenu. I know that I could add a
> "name" or class to either the head or subhead. I wouod rather have
> jQuery find these so that I don't have any markup in the HTML
> necessary to make this work.
>
> On Nov 29, 11:21 pm, "Jeffrey Kretz" <[EMAIL PROTECTED]> wrote:
>
> > Okay, so I stepped through the code.  I'm going to hazard a guess that you
> > didn't want the previous element but the parent element.
>
> > $('#LHNav ul').prev() returns an H1 and an array of A elements.
>
> > This is because prev looks for the sibling element just in front of the
> > current one.
>
> > $('#LHNav ul').parent('li') will, I believe, return the results you are
> > looking for.
>
> > JK
>
> > P.S. IMO, the really odd thing is why FF worked when I believe it should
> > have returned an empty set.  Anyone else have any ideas?
>
> > -----Original Message-----
> > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
>
> > Behalf Of flycast
> > Sent: Saturday, November 29, 2008 8:29 PM
> > To: jQuery (English)
> > Subject: [jQuery] Re: Problem with prev() in IE
>
> > Yes...http://www.trinityacademy.org/testNavigation/
>
> > On Nov 29, 6:22 pm, "Jeffrey Kretz" <[EMAIL PROTECTED]> wrote:
> > > I've used something very similar to that in IE6 without any problems.
>
> > > Could you post a demo page?
>
> > > JK
>
> > > -----Original Message-----
> > > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
>
> > > Behalf Of flycast
> > > Sent: Saturday, November 29, 2008 3:57 PM
> > > To: jQuery (English)
> > > Subject: [jQuery] Problem with prev() in IE
>
> > > This code works fine in FF and Safari but (surprise, surprise) not in
> > > IE6.
>
> > > $("#LHNav ul").prev('li').each(function(){
> > > alert("Loop");
> > > });
>
> > > I have narrowed it down to giving prev() some value to filter by. IF I
> > > try it like this:
> > > (notice the missing "li")
>
> > > $("#LHNav ul").prev().each(function(){
> > > alert("Loop");
> > > });
>
> > > It works fine. Why does IE always have to be so buggy and particular?

Reply via email to