[jQuery] small and maybe useful "else" extension

[jQuery] small and maybe useful "else" extension


I sometimes have the need to select a group of elements, perform one
action on one or more, and a different action on the rest of them, for
example:
$("div")
.eq(1)
.fadeTo(1000, 1)
.end()
.not(":eq(1)")
.fadeTo(1000, 0);
This is a trivial example, but sometimes the "eq(1)" is a more
complicated selector which needs to be entered into both a filter()
and a not() operation.
As a shorthand, I wrote a small extension:
jQuery.fn.else = function() {
    return this.end().not(this);
};
$("div")
.eq(1)
.fadeTo(1000, 1)
.else()
.fadeTo(1000, 0);
(I realize else is a reserved word: it works in Firefox, but you could
also use "others" if you want to avoid the potential conflict.)
oliver