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 <morni...@gmail.com> wrote: > Can you just make life REALLY easy on yourself and put the text in a > <span> tag or something? > > ie/ > > <ul> > <li><span>List Item1</span></li> > <li><span>List Item2</span> > <ul> > <li>Sub Item1</li> > <li>Sub Item2</li> > </ul> > </li> > </ul> > > 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" <amazz...@gmail.com> wrote: > > > Hi, > > I'm trying to traverse a list that has some sub-lists nested, i.e. > > <ul> > > <li>List Item1</li> > > <li>List Item2 > > <ul> > > <li>Sub Item1</li> > > <li>Sub Item2</li> > > </ul> > > </li> > > </ul> > > > 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