sorry for the misinterpretation. Yeah, that seems like a bug.
$(':not(div:has(div))') gave the exact same results as $('*').not
('div:has(div)') in jQuery 1.2.6.
In 1.3 $(':not(div:has(div))') excludes <html>, <body> and any <div>
elements.
On Jan 19, 7:07 pm, jdwbell <[email protected]> wrote:
> Thanks for the reply. That would give me every non-div element which
> contained a div. In the original example I was looking for every div
> which did not contain another div plus every other non-div element.
> Based on John's reply I'm guessing there is bug since $(':not(div:has
> (div))') is supposed to be equivalent to
> $('*').not('div:has(div)') but doesn't seem to be in the example I've
> given.
>
> On Jan 17, 2:20 pm, Ricardo Tomasi <[email protected]> wrote:
>
> > 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 donotcontain 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 isnota 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!