From what I read in the docs, end() will return the initial object. In my case this should return $(this), right?
$('.el').delegate('a.off', 'click', function(){
$(this).parents('div').find('a').removeClass('active').end().addClass('active');
...
});
but it doesn’t seem to work. I don’t get the addClass('active') applied on the original element (the link a.off).
Not the initial object, the previously selected elements, which would be
.parents('div')in this case. Think about it as a stack and every time you change the selection of elements, they get added to the stack, and.end()removes the last entry of the stack. You’d have to call.end()twice.But instead you can also rearrange your method calls and use
notto filter out the particular element: