Excluding $(this) from jQuery selector

If you want to attach a click (for example) event to a set of elements but then do something with all those elements except the one clicked that can be achieved easily with the .not() function in jQuery:

Var $contentLinks = $(“.content a”);
$contentLinks.click(function() {

Note, caching of the set outside the click function to help from a performance point of view.

Related Links


Leave a Reply

Your email address will not be published. Required fields are marked *