Skip to content

Instantly share code, notes, and snippets.

@onestepcreative
Created March 20, 2014 19:05
Show Gist options
  • Select an option

  • Save onestepcreative/9671405 to your computer and use it in GitHub Desktop.

Select an option

Save onestepcreative/9671405 to your computer and use it in GitHub Desktop.
javascript selector not requiring jQuery
var S = function (selector, context) {
if (typeof selector === 'string') {
if (context) {
var cont;
if (context.jquery) {
cont = context[0];
if (!cont) return context;
} else {
cont = context;
}
return $(cont.querySelectorAll(selector));
}
return $(document.querySelectorAll(selector));
}
return $(selector, context);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment