3 lines of code, that make writing pure JS so much quicker
by leaverou
HTML
<h1>3 lines of code, that make writing pure JS so much quicker</h1>
<p>Look at the JavaScript tab</p>
<p>PS: Yes, I know it’s easy, but I wanted to have it somewhere for quick copying & pasting.</p>
CSS
body {
font-family:sans-serif;
background:#ddd;
text-shadow:0 2px white;
}
JavaScript
function $(id) { return document.getElementById(id); }
function $t(tag, con) { return (con || document).getElementsByTagName(tag); }
function $$(expr, con) { return (con || document).querySelectorAll(expr); }