Skip to content

Instantly share code, notes, and snippets.

@kawsaramin101
Last active May 2, 2022 16:23
Show Gist options
  • Save kawsaramin101/4b2eb09aeafd1e4f6a745df5761d9460 to your computer and use it in GitHub Desktop.
Save kawsaramin101/4b2eb09aeafd1e4f6a745df5761d9460 to your computer and use it in GitHub Desktop.
function $(el) {
const type = el.charAt(0);
switch (type) {
case "#":
return document.querySelector(el);
break;
case ".":
return document.querySelectorAll(el);
break;
default:
return document.getElementsByTagName(el);
}
}
function $(e){switch(e.charAt(0)){case"#":return document.querySelector(e);case".":return document.querySelectorAll(e);default:return document.getElementsByTagName(e)}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment