Skip to content

Instantly share code, notes, and snippets.

@addyosmani
Forked from gbakernet/jQuery.atLeastOne.js
Created November 20, 2010 17:42
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 addyosmani/708000 to your computer and use it in GitHub Desktop.
Save addyosmani/708000 to your computer and use it in GitHub Desktop.
//For use on the jquery functions that except selectors
jQuery.fn.atLeastOne = function(prop, selectorsArr) {
var ret = 0, self = this,
testSelector = function(value){
return self[prop].apply(self, [value]).size() > 0;
};
$.each(selectorsArr, function(i, value){
ret = testSelector(value);
// break loop if found
if(ret) { return false }
})
return ret;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment