Created
July 15, 2015 15:22
-
-
Save edirpedro/bf64c4f046437cf50458 to your computer and use it in GitHub Desktop.
Search for the first element found in the objects array passed
This file contains hidden or 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
/* | |
* Function findFirst() will search for the first element found in the objects array passed | |
* $.findFirst('selector', [element, document]); | |
*/ | |
$.extend({ | |
findFirst: function(selector, objs) { | |
for (var i in objs) { | |
var elem = jQuery(selector, objs[i]); | |
if (elem.length) return elem; | |
} | |
return jQuery(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment