Want to attach an Event Handler/Listener to some links using the “delegate()” method, but I want to attach it only to links with certain classes:
The links are inside a larger block called “slider”, so what I use to bind the Event Listener to all the links is:
$(“#slider”).delegate(“a”, “click”, myFunction);
But I want to bind the #slider method to only the links that have a class that does NOT contain “nivo-control”.
$("#slider").delegate("a[class!='nivo-control']", "click", myFunction);
it doesn’t work, not even for the links that ONLY have a class of “nivo-control”.
$("#slider a").delegate("a[class!='nivo-control']", "click", myFunction);
doesn’t work either.
I could also select the links by checking whether they do NOT have a “rel” attribute, but this doesn’t work either:
$("#slider").delegate("a[rel!='']", "click", function() { alert("hey");});
Following filter/selector you may try.