Last active
January 18, 2016 12:52
-
-
Save kotarok/d0780133c6bb76635886 to your computer and use it in GitHub Desktop.
Minimum fake jQuery
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
var $ = function(q, f){ | |
return [][(f? 'forEach': 'slice')].call(document.querySelectorAll(q), f || 0); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$(
selector
,function (optional)
);Returns selected elements by given
selector
in array. Or iffunction
is given, iterate it with taking each element as an argument.