"Uppermost" in the sense that between them and the all-embracing
div.#container there's nothing but div.wrappers -- no other divs with
span.bullet children in the ancestry. Wizzud's expression performs
exactly the right selection.
Thanks for your input, though. (I'd also forgotten about the
usefulness of the :first and :last filters. I have uses for them in
other contexts.)
Ed
On May 22, 10:40 pm, Karl Swedberg <[EMAIL PROTECTED]> wrote:
> I'm not sure what you mean by "uppermost," but you can select the
> wrapper div closest to the span with $
> ('span.bullet').parents('div.wrapper:first') or furthest out from the
> span with $('span.bullet').parents('div.wrapper:last')
>
> --Karl
> _________________
> Karl Swedbergwww.englishrules.comwww.learningjquery.com
>
> On May 22, 2008, at 4:54 PM, EdMartin wrote:
>
>
>
> > I have a setup like this
>
> > <div id="container">
> > <div class="wrapper">
> > <div class="wrapper">
> > <div><span class="bullet">Bullet</span>
> > <!-- other stuff, potentially inner divs also containing bullets --
>
> > </div>
> > </div>
> > </div>
> > </div>
>
> > where there is an unknown number of wrapping "wrapper" divs. I want to
> > select the uppermost divs that contain a span.bullet, regardless of
> > the amount of wrapping. All such uppermost span.bullet-containg divs
> > will be wrapped to the same depth. But any or all of them may contain
> > other span.bullet-containing divs -- I don't want to select such non-
> > uppermost divs.
>
> > In practice, the depth of wrapping is probably only 0, 1, 2, or 3. So
> > I could deal with each of those separately, like this:
>
> > $( '#container' ).children().filter( ':has( span.bullet )' ) // no
> > wrapping
> > $
> > ( '#container
> > ' ).children
> > ().filter( '.wrapper' ).children().filter( ':has( span.bullet )' ) //
> > 1 layer of wrapping
>
> > and so on. But surely there has to be a more elegant way.
>
> > Any suggestions?