Skip to content

Instantly share code, notes, and snippets.

@kotarok
Last active January 18, 2016 12:52
Show Gist options
  • Save kotarok/d0780133c6bb76635886 to your computer and use it in GitHub Desktop.
Save kotarok/d0780133c6bb76635886 to your computer and use it in GitHub Desktop.
Minimum fake jQuery
var $ = function(q, f){
return [][(f? 'forEach': 'slice')].call(document.querySelectorAll(q), f || 0);
};
@kotarok
Copy link
Author

kotarok commented Jan 18, 2016

$(selector, function (optional));
Returns selected elements by given selector in array. Or if function is given, iterate it with taking each element as an argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment