Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
13 lines (8 sloc) 370 Bytes

jquery.or

Add to the set of matched elements if the current set is empty. Useful for specifying a fallback or base case to still act upon.

Examples:

// tr.last, failing that just the last tr then.
$('tr.last').or('tr:last').toggle();

// find the closest parent form, but fall back to the target otherwise.
$(e.target).closest('form').or(e.target);