Skip to content

Instantly share code, notes, and snippets.

@AllThingsSmitty
Last active August 20, 2022 13:32
Show Gist options
  • Save AllThingsSmitty/f9029e6236a7c2a03203 to your computer and use it in GitHub Desktop.
Save AllThingsSmitty/f9029e6236a7c2a03203 to your computer and use it in GitHub Desktop.
Use querySelector with .bind() as a shortcut to familiar function names
// returns first element selected - $('input[name="food"]')
var $ = document.querySelector.bind(document);
// return array of selected elements - $$('img.dog')
var $$ = document.querySelectorAll.bind(document);
// Credit: https://twitter.com/wesbos/status/608341616173182977
@AllThingsSmitty
Copy link
Author

bling.js may have the best answer for this use case.

@wesbos
Copy link

wesbos commented Aug 25, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment