views:

32

answers:

2

I'm currently taking over any links on the page that begin with "users":

$('a[href^="/users/"]').live('click', function(event) {

...however, this is a little greedy. I want to exclude any links to "stuff" that are NOT with the "versions" class. I tried:

$('a[href^="/users/"]').not('div.versions a').live('click', function(event) {

...but this breaks the whole block. My next guess it is breaking because of "live" -- with the way events trickle up.

Any ideas? Is there a better way to do this?

+1  A: 

Try this:

$('div:not(.versions) a[href^="/users/"]').live('click', function(event) {
BoltClock
but why it doesn't work in his version? seems to be working script...
Syom
This will work as long as the `a[href^="/users/"]` is a descendant of a `div`. If there are any that are (for example) a direct child of `<body>`, it wouldn't fire the handler. Doing `:not(.versions) a[href^="/users/"]` would fix it.
patrick dw
...actually `:not(.versions) a[href^="/users/"]` doesn't seem to be a fix.
patrick dw
+2  A: 

try merging not in the main selector:

$('a[href^="/users/"]:not(div.versions a)').live('click', function(event) {

Check here as well: http://stackoverflow.com/questions/3635471/not-with-live-not-working, seems to be the same problem.

aularon