Created
January 4, 2017 00:18
-
-
Save bwll/b40c6836c8a58984b0094829bae8070b to your computer and use it in GitHub Desktop.
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
/* | |
* https://developer.mozilla.org/en-US/Add-ons/Code_snippets/QuerySelector | |
*/ | |
function $ (selector, el) { | |
if (!el) {el = document;} | |
return el.querySelector(selector); | |
} | |
function $$ (selector, el) { | |
if (!el) {el = document;} | |
return el.querySelectorAll(selector); | |
// Note: the returned object is a NodeList. | |
// If you'd like to convert it to a Array for convenience, use this instead: | |
// return Array.prototype.slice.call(el.querySelectorAll(selector)); | |
} | |
alert($('#myID').id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment