Created
December 10, 2011 16:01
-
-
Save Raynos/1455456 to your computer and use it in GitHub Desktop.
tiny select. Selecting has never been so awesome \o/
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
// Pretty fast - http://jsperf.com/select-vs-natives-vs-jquery | |
/* | |
By, shortcuts for getting elements. | |
*/ | |
var By = { | |
id: function (id) { return document.getElementById(id) }, | |
tag: function (tag, context) { | |
return (context || document).getElementsByTagName(tag) | |
}, | |
"class": function (klass, context) { | |
return (context || document).getElementsByClassName(klass) | |
}, | |
name: function (name) { return document.getElementsByName(name) }, | |
qsa: function (query, context) { | |
return (context || document).querySelectorAll(query) | |
}, | |
qs: function (query, context) { | |
return (context || document).querySelector(query) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
lol, nice