Skip to content

Instantly share code, notes, and snippets.

@barneycarroll
Last active December 17, 2015 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barneycarroll/5671806 to your computer and use it in GitHub Desktop.
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.
$.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