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:58 AM, Mark Gibson wrote:


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 <ul>, but continue the search at the same and
shallower levels.
Is  there a way to do this with a $.expr[':'] plugin?

On Nov 11, 11:24 am, Klaus Hartl <[EMAIL PROTECTED]> wrote:
That won't work. :first-child will give you *all* uls that are the
first child of any element:

<div id="container">
    <ul><!-- is first child -->
        <li>
            <ul> ... </ul><!-- is first child -->
        </li>
    </ul>
</div>

If you need the topmost ul use the ">" combinator:

$('#container > u')

Oh, jQuery has some documentation about 
selectors:http://docs.jquery.com/Selectors

En plus knowing the spec doesn't hurt 
either:http://www.w3.org/TR/CSS21/selector.htmlhttp://www.w3.org/TR/css3-selectors/

--Klaus

On 11 Nov., 02:07, "Hector Virgen" <[EMAIL PROTECTED]> wrote:

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-20011113/#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 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 <ul> lists on a page, which in turn contain sub-
lists, and so on.
Is there a selector I can use to find all the topmost <ul> elements.

I've been raking my brains over this, and can't see a way with css
style selectors,
have i overlooked something?

Ideally I'd like to do:
$('ul:topmost')

or:
$('#container ul:topmost')

Cheers
- Mark

Reply via email to