Perhaps this is naive of me, but I was expecting this to work: $(this).nextAll('a').andSelf().removeClass ('star_selected').triggerHandler('mouseout');
It is used in a rating system I wrote, where there are 5 <a> tags in a row. If you click on one, this fires (adds a class name on all previous and this one, and fires the mouseout event). It works just fine for stars 1-4, but fails on #5. The reason is obvious, in that #5 has no nextAll, but I would not have thought that it alone would break the chain. IF I do this, it works: $(this).nextAll('a').removeClass('star_selected'); $(this).removeClass('star_selected').triggerHandler('mouseout'); But I do not wish to repeat myself with the removeClass part. The mouseout needs to be fired last, so I cannot simply reorder the original. Any idea how this can be done in one statement, without repeating myself? Michael