Created
September 18, 2020 02:32
-
-
Save doceazedo/d9a05f2d3cf7f3d5c40b9c76c8a3111b to your computer and use it in GitHub Desktop.
jQuery-like querySelector and querySelectorAll shorthand
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 $ (sel) { | |
var el = document.querySelectorAll(sel); | |
if (el.length > 1) { | |
return el; | |
} else { | |
return el[0]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment