[jQuery] Re: Anyone know how to find the topmost elements of a specific type?

2008-11-26 Thread ricardobeat
I sketched up a plugin for this. It's at http://ff6600.org/j/jquery.dig.js Live example at http://jsbin.com/ugena/ It just steps throught the children with the tag given and executes a function for each one, passing it it's 'hierarchy level' in relation to the container where the plug-in was ca

[jQuery] Re: Anyone know how to find the topmost elements of a specific type?

2008-11-26 Thread Mark Gibson
I don't think I stated my problem fully. What I'm trying to do it process the elements recursively, so using the 's as an example: 1. Find the shallowest 's (Karl's solutions would work here). 2. For each found: 3. Add content to the . 4. Find the next shallowest within each . 5. Recurse from

[jQuery] Re: Anyone know how to find the topmost elements of a specific type?

2008-11-17 Thread Karl Swedberg
Hi Mark, I took a look at your original post again, and from your description there it looks like this would work: $('ul').filter(function() { return !$(this).parents('ul').length; }) --Karl Karl Swedberg www.englishrules.com www.learningjquery.com On Nov 17, 2008, at 10:

[jQuery] Re: Anyone know how to find the topmost elements of a specific type?

2008-11-17 Thread Mark Gibson
The trouble is that the elements i'm looking for are not necessarily direct children of the container, so > isn't going to work. What I really need is to stop jQuery from searching any deeper once it finds the first , but continue the search at the same and shallower levels. Is there a way to do

[jQuery] Re: Anyone know how to find the topmost elements of a specific type?

2008-11-11 Thread Klaus Hartl
That won't work. :first-child will give you *all* uls that are the first child of any element: ... If you need the topmost ul use the ">" combinator: $('#container > u') Oh, jQuery has some documentation about selectors: http://docs.jquery.com/Select

[jQuery] Re: Anyone know how to find the topmost elements of a specific type?

2008-11-10 Thread Hector Virgen
Oops, it's actually $('#container ul:first-child') Here's a nifty page of CSS3 selectors: http://www.w3.org/TR/2001/CR-css3-selectors-2003/#selectors -Hector On Mon, Nov 10, 2008 at 5:06 PM, Hector Virgen <[EMAIL PROTECTED]> wrote: > $('#container ul:first') should give you the first UL in

[jQuery] Re: Anyone know how to find the topmost elements of a specific type?

2008-11-10 Thread Hector Virgen
$('#container ul:first') should give you the first UL in the container -Hector On Mon, Nov 10, 2008 at 4:50 PM, Mark Gibson <[EMAIL PROTECTED]> wrote: > > Anyone know how I can find the topmost elements of a certain type, eg. > > Say I have several lists on a page, which in turn contain sub- >