Skip to content

Instantly share code, notes, and snippets.

@yeco
Forked from potfur/$.js
Created May 14, 2013 18:56
Show Gist options
  • Save yeco/5578474 to your computer and use it in GitHub Desktop.
Save yeco/5578474 to your computer and use it in GitHub Desktop.
// Based on https://github.com/james2doyle/saltjs
window.$ = function(s) {
return document[{
'#': 'getElementById',
'.': 'getElementsByClassName',
'@': 'getElementsByName',
'=': 'getElementsByTagName'}[s[0]]
|| 'querySelectorAll'](s.slice(1))
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment