Last active
August 29, 2015 14:09
-
-
Save duzun/187785d63ccb95da8883 to your computer and use it in GitHub Desktop.
findAll() jQuery plugin - a combination of filter, closest and find in one call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Find selector in this and descendants of this. | |
* if up == true, search parents as well. | |
* | |
*/ | |
;(function (global) { | |
var $ = global.jQuery || global.Zepto; | |
$.fn.findAll = function findAll(selector, up) { | |
var self = this | |
, search = up ? self.closest(selector) : self.filter(selector) | |
; | |
return search.add(self.not(search).find(selector)); | |
} ; | |
})(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment