Skip to content

Instantly share code, notes, and snippets.

@jbsulli
Last active September 19, 2017 20:20
Show Gist options
  • Save jbsulli/6ad511680a235341d536725e9b30b846 to your computer and use it in GitHub Desktop.
Save jbsulli/6ad511680a235341d536725e9b30b846 to your computer and use it in GitHub Desktop.

Query

  • document.querySelector(): returns first matching element
  • document.querySelectorAll(): returns all matching elements
  • document.getElementById(id)

DOM Node

  • addEventListener(event, cb)
  • appendChild(node)
  • childNodes
  • classList
    • add(cl)
    • contains(cl)
    • toggle(cl)
    • remove(cl)
  • cloneNode(true)
  • closest(query)
  • getAttribute(att)
  • hasChildNodes()
  • matches(query)
  • nextSibling
  • parentNode
  • removeChild(child_node)
  • setAttribute(att, val)

Document

  • document.createElement(tag_name)
  • document.addEventListener('DOMContentLoaded', cb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment