Skip to main content

Bug Tracker

Side navigation

#3976 closed bug (worksforme)

Opened January 23, 2009 08:10PM UTC

Closed November 22, 2010 12:39PM UTC

:not returning different results than .not

Reported by: jdwbell Owned by: jdwbell
Priority: low Milestone:
Component: selector Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:
Description

In the example given below these two return the expected elements (exclude only divs which contain other divs):

$('*').not('div:has(div)')

$('*').not($('div:has(div)'))

but these three do not (they seem to be excluding all divs as well as all other elements which contain divs:

$(':not(div:has(div))')

$('*:not(div:has(div))')

$('*').filter(':not(div:has(div))')

Tested on Chrome, Firefox, IE6, and Safari.

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="jquery-1.3.1.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>
Attachments (0)
Change History (4)

Changed January 25, 2009 06:29PM UTC by dmethvin comment:1

owner: → john

Changed October 14, 2009 01:00AM UTC by dmethvin comment:2

component: unfilledselector
description: In the example given below these two return the expected elements (exclude only divs which contain other divs): \ \ $('*').not('div:has(div)') \ \ $('*').not($('div:has(div)')) \ \ but these three do not (they seem to be excluding all divs as well as all other elements which contain divs: \ \ $(':not(div:has(div))') \ \ $('*:not(div:has(div))') \ \ $('*').filter(':not(div:has(div))') \ \ Tested on Chrome, Firefox, IE6, and Safari. \ \ 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="jquery-1.3.1.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>In the example given below these two return the expected elements (exclude only divs which contain other divs): \ \ $('*').not('div:has(div)') \ \ $('*').not($('div:has(div)')) \ \ but these three do not (they seem to be excluding all divs as well as all other elements which contain divs: \ \ $(':not(div:has(div))') \ \ $('*:not(div:has(div))') \ \ $('*').filter(':not(div:has(div))') \ \ Tested on Chrome, Firefox, IE6, and Safari. \ \ 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="jquery-1.3.1.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> \ }}}
milestone: 1.3.21.3.3
summary: :not returning different results then .not:not returning different results than .not
version: 1.3.11.3.2

Changed October 29, 2010 03:22PM UTC by rwaldron comment:3

milestone: 1.4
owner: johnjdwbell
priority: majorlow
status: newpending

Please provide a reduced jsFiddle test case, thanks!

Changed November 22, 2010 12:39PM UTC by jitter comment:4

_comment0: [http://jsfiddle.net/jitter/gjJpC/ test case]. Can reproduce this. All for variants yield the same correct result. If you feel this ticket was incorrectly closed, feel free to report back and reopen with a reproducible test case.1290449971207604
resolution: → worksforme
status: pendingclosed

test case. Can't reproduce this. All for variants yield the same correct result. If you feel this ticket was incorrectly closed, feel free to report back and reopen with a reproducible test case.