Last active
December 17, 2015 20:59
-
-
Save barneycarroll/5671806 to your computer and use it in GitHub Desktop.
FFS stands for the Filter / Find Solution. You know how you get stumped when your jQuery find is returning nothing, and yet you know you've got a match, like, right there? Or vice versa? Perform first filter, then find, on each member of the collection. Wrote because of repeatedly stubbing my toes on jQuery Ajax responses.
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
$.fn.FFS = function FilterFindSolution(){ | |
var a = ['filter','find']; | |
var p = [].slice.call(arguments); | |
var y = $(); | |
this.each(function(){ | |
var e = $(this); | |
var i = -1; | |
while(i++ < 1) y = y.add(e[a[i]].apply(e, p)); | |
}); | |
return y; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment