Skip to content

Instantly share code, notes, and snippets.

@Fabiantjoeaon
Created May 26, 2017 20:25
Show Gist options
  • Save Fabiantjoeaon/f4197e26df7c1ffd20238e5c07c9196e to your computer and use it in GitHub Desktop.
Save Fabiantjoeaon/f4197e26df7c1ffd20238e5c07c9196e to your computer and use it in GitHub Desktop.
No need for jQuery, just use Bling (by @paulirish @wesbos)
const $ = document.querySelector.bind(document);
const $$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function(name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
NodeList.prototype.on = NodeList.prototype.addEventListener = function(name, fn) {
this.forEach((elem, i) => {
elem.on(name, fn);
});
}
export {$, $$};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment