It seems that I have a misunderstanding about how .is() worked. Given this html: <div class="test"> <div id="x">Test DIV</div> </div>
I was expecting this: alert( $('#x').is('div:not(.test) div') ); to return "false". Instead, it returns true. Can I not check for parent conditions in .is()? I see that according to the docs, is() uses filter() internally. So I tried this: alert ( $('div').size() ); // Correctly alerts 2 and this: alert ( $('div:not(.test) div').size() ); // Correctly alerts 0 but this: alert ( $('div').filter('div:not(.test) div').size() ); // Alerts 3 It looks like the internal div is being duplicated in the results, which I don't understand either. I would have expected 0, because no div elements on the page actually match the filter() expression. I am probably just misunderstanding the internal workings of these methods - can anyone clarify? (all my testing is in IE6 only, btw) My real-world goal is to make sure an element has no parent with a certain class, and take action only if this is true. I wanted to use the .is() method above, but I am doing this instead for now: if (o.parents().filter('div.unwantedclass').size()==0) { ... } Is there a better way? Matt Kruse