I would like to suggest a tiny (98bytes) addition to jQuery traversing methods list.
.or( [selector/function] ) The method allows comfortable handling of situations where a selector is not matched.
There is a common case as follows:
$elem=$('someselector');
if($elem.length==0){
$elem=$('otherselector');
}
This can be changed to a simple statement:
$elem=$('someselector').or('otherselector');
A complete example including additional use-cases is attached and hanged
here
I am also wondering if this function should always use .find() or copy a previous behaviour. Traversing method to use could be passed as a second argument. See
TODO? - missbehaviour example.
Edit:
BBonifield helped me on stackoverflow and I will be able to fix the missbehaviour if it's supposed to be fixed. I hope to shrink the fix to about 200bytes