Skip to content

Instantly share code, notes, and snippets.

@therealFoxster
Last active February 14, 2024 04:17
Show Gist options
  • Save therealFoxster/ce81964136893349d3e15f74e7ff281f to your computer and use it in GitHub Desktop.
Save therealFoxster/ce81964136893349d3e15f74e7ff281f to your computer and use it in GitHub Desktop.
jQuery-like element selector
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