Bug Tracker

Opened 9 years ago

Last modified 9 years ago

#7194 closed feature

Suggested selector/function .or() — at Initial Version

Reported by: addyosmani Owned by:
Priority: low Milestone: 1.7
Component: selector Version: 1.4.3
Keywords: Cc:
Blocked by: Blocking:


From: http://forum.jquery.com/topic/traversing-or#14737000001495015 A suggestion for including support for or()

.or( [selector/function] ) The method allows comfortable handling of situations where a selector is not matched.

Suggested code:

    $.fn.or=function(a){var t=this;return t.length>0?t:(t=t.end())&&$.isFunction(a)?a.apply(t):a?t.find(a):t}

Additional use and test cases can be found here: http://www.jsfiddle.net/naugtur/rdEAu/

Change History (0)

Note: See TracTickets for help on using tickets.