Do you have a test page we can look at?

nextAll returns an empty object if there is no 'next', but it doesn't
interrupt the chain, there may be something else going on. I couldn't
reproduce your situation here, nextAll().andSelf() returns me the
original element.

- ricardo

On Dec 12, 10:39 am, Reepsy <mre...@gmail.com> wrote:
> 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

Reply via email to