Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
tiny select. Selecting has never been so awesome \o/
// 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)
}
}
@tblobaum

This comment has been minimized.

Copy link

commented Dec 10, 2011

lol, nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.