Last active
December 17, 2015 08:19
-
-
Save nickL/5579175 to your computer and use it in GitHub Desktop.
domSelect.js -- (super-light jquery like dom selection)
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(a) { | |
var b, c; | |
b = { | |
"#": "getElementById", | |
".": "getElementsByClassName", | |
"@": "getElementsByName", | |
"=": "getElementsByTagName", | |
"*": "querySelectorAll" | |
}; | |
c = /[=#@.*]/.exec(a)[0]; | |
return document[b[c]](a.split(c)[1]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: