Shouldn't it simply be
$(':not(div):has(div)') ?
Note that it gives you all the chain of parents to the element which
contains a DIV.
On Jan 16, 6:26 pm, jdwbell <[email protected]> wrote:
> Thank you very much for your reply. I am finding that with the
> example listed below these two work as expected (that is they are
> returning non divs and all divs which do not contain other divs):
>
> $('*').not('div:has(div)')
> $('*').not($('div:has(div)'))
>
> but these three:
>
> $(':not(div:has(div))')
> $('*:not(div:has(div))'
> $('*').filter(':not(div:has(div))')
>
> are excluding ALL divs as all other elements which contain divs
>
> Hopefully that explanation makes because I'm kind of confusing
> myself! I've tried this on IE 6 and Chrome with the same results.
>
> Thanks!
>
> <html>
> <head>
> <style>
> div, fieldset, p {
> border: ridge 1px silver;
> padding: 20px;
> margin: 20px;
> }
> .wrappedElement {
> border: ridge 2px #FF0000;
> }
> </style>
> <script type="text/javascript"
> src="../../scripts/jquery-1.3.js"></script>
> <script>
> $(function(){
> $(':not(div:has(div))').addClass('wrappedElement');
> //$('*:not(div:has(div))').addClass('wrappedElement');
> //$('*').filter(':not(div:has(div))').addClass('wrappedElement');
> //$('*').not('div:has(div)').addClass('wrappedElement');
> //$('*').not($('div:has(div)')).addClass('wrappedElement');
> })
> </script>
> </head>
> <body>
> <div>
> <div>
> <div>
> <p>paragraph surrounded by three divs</p>
> </div>
> </div>
> </div>
> <fieldset>
> <div>
> div surrounded by fieldset
> </div>
> </fieldset>
> </body>
> </html>
>
> On Jan 16, 1:50 pm, John Resig <[email protected]> wrote:
>
> > $(':not(div:has(div))') is equivalent to
> > $('*:not(div:has(div))') is equivalent to
> > $('*').filter(':not(div:has(div))') is equivalent to
> > $('*').not('div:has(div)')
>
> > Hope that helps to answer your question :)
>
> > --John
>
> > On Fri, Jan 16, 2009 at 11:24 AM, jdwbell <[email protected]> wrote:
>
> > > Here I am trying to get every element which is not a div that contains
> > > another div.
>
> > > Is $(':not(div:has(div))') supposed to now be equivalent to $('*').not
> > > ($('div:has(div)')) or am I misunderstanding what the change was (I'm
> > > just getting started with jQuery)?
>
> > > Thanks!