Skip to content

Instantly share code, notes, and snippets.

@ofca
Last active February 20, 2021 13:30
Show Gist options
  • Save ofca/5577178 to your computer and use it in GitHub Desktop.
Save ofca/5577178 to your computer and use it in GitHub Desktop.
// based on https://gist.github.com/Potfur/5576225 & https://github.com/james2doyle/saltjs
// more info: https://plus.google.com/109231487156400680487/posts/63eZzzrBSb6
window.$ = function(s) {
var c = {
'#': 'ById',
'.': 'sByClassName',
'@': 'sByName',
'=': 'sByTagName'}[s[0]];
return document[c?'getElement'+c:'querySelectorAll'](s.slice(1))
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment