Skip to content

Instantly share code, notes, and snippets.

@aaronlidman
Created September 1, 2013 04:37
Show Gist options
  • Select an option

  • Save aaronlidman/6402357 to your computer and use it in GitHub Desktop.

Select an option

Save aaronlidman/6402357 to your computer and use it in GitHub Desktop.
window.select = function(query) {
var d = document;
if (query.split(' ').length > 1 ||
query.split(',').length > 1 ||
query.split('[').length > 1 ||
query.split(':').lenght > 1) return d.querySelectorAll(query);
if (query.charAt(0) === '#') return d.getElementById(query.substring(1));
if (query.charAt(0) === '.') return d.getElementsByClassName(query.substring(1));
return d.getElementsByTagName(query);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment