Skip to content

Instantly share code, notes, and snippets.

@jhafner
Last active February 6, 2018 18:54
Show Gist options
  • Save jhafner/30cadb8c424ad094f3aa5c3b2670a8b1 to your computer and use it in GitHub Desktop.
Save jhafner/30cadb8c424ad094f3aa5c3b2670a8b1 to your computer and use it in GitHub Desktop.
3 lines of code, that make writing pure JS so much quicker. Borrowed mostly from http://jsfiddle.net/leaverou/hRz8K/embedded/result,js/
function $(id) { return document.getElementById(id); }
function $c(class) { return document.getElementsByClassName(class); }
function $t(tag, container) { return (container || document).getElementsByTagName(tag); }
function $$(expr, container) { return (container || document).querySelectorAll(expr); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment