Created
May 11, 2011 00:14
-
-
Save ippa/965662 to your computer and use it in GitHub Desktop.
svetlo-modified
This file contains hidden or 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
// Modified: http://www.vcarrer.com/2011/04/svetlo-one-line-javascript-selector.html | |
function $(selector){ | |
var elements = Array.prototype.slice.call( document.querySelectorAll(selector) ) | |
var items = selector.split(" ") | |
return (items[items.length-1][0] == "#") ? elements[0] : elements // Return single element if fetching an ID | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment