[jQuery] nextAll Chaining when nextAll is Empty
This might sound naive, but I expected this to work:
$(this).nextAll('a').andSelf().removeClass
('star_selected').triggerHandler('mouseout');
It's from a star rating I wrote, where I have 5 <a> tags in a row. If
you click on one it removes a class from it and all that follow it,
and then fires the mouseout event. This works perfectly for stars 1-4,
but fails on #5, because there is no next. But I did not expect it to
ignore the rest of the chain. Everything after .nextAll is ignored. If
I break this into two lines, it works fine:
$(this).nextAll('a').removeClass('star_selected');
$(this).removeClass('star_selected').triggerHandler('mouseout');
But I am repeating myself with the removeClass. Can anyone see a way
to combine these back into one statement? The mouseout has to go last.
Michael