Last active
February 14, 2024 04:17
-
-
Save therealFoxster/ce81964136893349d3e15f74e7ff281f to your computer and use it in GitHub Desktop.
jQuery-like element selector
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
export const $ = s => s.startsWith("#") && ![".", " ", ">"].some(c => s.includes(c)) | |
? document.getElementById(s.substring(1)) | |
: document.querySelector(s); | |
export const $$ = s => document.querySelectorAll(s); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment