Last active
April 7, 2018 07:22
-
-
Save andirady/87979e7b9e8fb2ee49df83287c6536b8 to your computer and use it in GitHub Desktop.
Aliases for JS methods
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
function $(a,b) { | |
if (b === undefined) | |
return document.querySelector(a); | |
return a.querySelector(b); | |
} | |
function $$(a,b) { | |
if (b === undefined) | |
return document.querySelectorAll(a); | |
return a.querySelectorAll(b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Aliases for querySelector and querySelectorAll. Example usage: