[jQuery] list traversing

2009-02-05 Thread amazz...@gmail.com

Hi,
I'm trying to traverse a list that has some sub-lists nested, i.e.

List Item1
List Item2

Sub Item1
Sub Item2




I'm trying to grab the text of List Item2, but without the text of the
sublist items. Right now if I use:
$('ul li').text()   -- it returns the text of the List Item and the
text of any sub items.

I'm thinking I may have to write a regular expression to filter out
the sublist, but was wondering if jQuery could handle this? Any ideas
appreciated.

AM


[jQuery] Re: list traversing

2009-02-05 Thread amazz...@gmail.com

You know how sometimes you are working on a problem and you stare at
it so long that the most obvious answers escape you until someone
points it out and it is like a smack in the face?

Yeah. Serious 'duh' moment on my part. Thanks.

On Feb 5, 3:32 pm, MorningZ  wrote:
> Can you just make life REALLY easy on yourself and put the text in a
>  tag or something?
>
> ie/
>
> 
>     List Item1
>     List Item2
>         
>             Sub Item1
>             Sub Item2
>         
>     
> 
>
> then
>
> http://docs.jquery.com/Selectors/firstChild
>
> would make it a snap to get the text()
>
> On Feb 5, 3:00 pm, "amazz...@gmail.com"  wrote:
>
> > Hi,
> > I'm trying to traverse a list that has some sub-lists nested, i.e.
> > 
> >     List Item1
> >     List Item2
> >         
> >             Sub Item1
> >             Sub Item2
> >         
> >     
> > 
>
> > I'm trying to grab the text of List Item2, but without the text of the
> > sublist items. Right now if I use:
> > $('ul li').text()   -- it returns the text of the List Item and the
> > text of any sub items.
>
> > I'm thinking I may have to write a regular expression to filter out
> > the sublist, but was wondering if jQuery could handle this? Any ideas
> > appreciated.
>
> > AM