$('span.bullet').parent().filter(function(){
    return !$(this).parents('div:has(>span.bullet)').length;
  });

On May 22, 9:54 pm, EdMartin <[EMAIL PROTECTED]> 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?

Reply via email to