Skip to main content

Bug Tracker

Side navigation

#6260 closed bug (worksforme)

Opened March 10, 2010 10:35PM UTC

Closed October 03, 2010 10:48PM UTC

Selector does not work properly when using multiple ":not()"s on same element

Reported by: musicisair Owned by:
Priority: undecided Milestone: 1.4.3
Component: event Version: 1.4.2
Keywords: delegate selectors not Cc:
Blocked by: Blocking:

In the following HTML


<a href="#">Should alert when clicked.</a>

<a href="#" class="one">Should not alert when clicked.</a>

<a href="#" class="two">Should not alert when clicked.</a>

<script src="js/jquery-1.4.2.js"></script>







$(...).delegate("a:not(.one,.two)","click",...) does work.

Attachments (0)
Change History (1)

Changed October 03, 2010 10:48PM UTC by addyosmani comment:1

priority: → undecided
resolution: → worksforme
status: newclosed

In your original logic based on your HTML/JS supplied:


a is not 'one', then it is either link 0 or link 2

a is not 'two', then it is either link 0 or link 1

on the whole this would result in the set [0,2,0,1] being assigned an alert of 'DELEGATED!' so any link clicked would fire this off. You then supplied a slightly different case (a:not(.one,.two)) which also wouldn't work.

Rather than doing this, if you are trying to just prevent links 'one' and 'two' from firing the alert whilst using delegate to still assign the click to any links, you can do this:











Both of these work as desired.