Skip to content

Instantly share code, notes, and snippets.

@snowman-repos
Created February 6, 2014 08:10
Show Gist options
  • Save snowman-repos/8840099 to your computer and use it in GitHub Desktop.
Save snowman-repos/8840099 to your computer and use it in GitHub Desktop.
Selectors API, without jQuery
element = document.querySelector "div"
elements = document.querySelectorAll ".container div"
navigation = document.querySelector "nav"
links = navigation.querySelectorAll "a"
# This gives us simple dollar function and event binding
$ = document.querySelectorAll.bind document
Element::on = Element::addEventListener
# This is how you use it
$(".element")[0].on "touchstart", handleTouch, false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment