function $(selector, elem) { var selects = (elem || document).querySelectorAll(selector); var empty = selects && selects.length == 0; return !empty && selector.trim()[0] == "#" ? selects[0]: selects; }