Created
June 29, 2016 19:33
-
-
Save neenhouse/7f54a7848e7c7d5e8a017ab4ce18344e to your computer and use it in GitHub Desktop.
Micro DOM Selector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.$ = $; | |
function $(s) { | |
let 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