Logo

JavaScript Web APIs Cheat Sheet (In progress…)

Print

Document/Element

Methods: selectors

querySelectorquerySelector(selector) // First element Documentation
querySelectorAllquerySelectorAll(selectors) // Array of elems. Documentation

Methods: create/modify

createElement()createElement(tag) Documentation

EventTarget

Methods

addEventListener()object.addEventListener(type,listener,options) Documentation
removeEventListener()object.removeEventListener(type,listener) Documentation
dispatchEvent()dispatchEvent(event) Documentation

Element

Properties

attributesArray Documentation
classListadd(), remove(), replace(), toggle() Documentation
classNameclassName, className = '…' Documentation
childrenArray Documentation
innerTextinnerText = '…' // HTMLElement Documentation
innerHTMLinnerHTML, innerHTML = '…' Documentation
outerHTMLouterHTML, outerHTML = '…' Documentation
remove()el.remove() Documentation
stylestyle.backgroundColor = "purple" Documentation
tagnametagname, tagname= Documentation
blur()el.blur() // HTMLElement Documentation

Methods

closestclosest(selector) // Traverses parents Documentation
getAttributegetAttribute(name) Documentation
setAttributesetAttribute(name, value) Documentation
getBoundingClientRect()el.getBoundingClientRect() Documentation
insertAdjacentElementinsertAdjacentElement(position)
// beforebegin,afterbegin,beforeend,afterend Documentation

HTMLFormElement

Methods

reset()Form element to default values Documentation
submit()Submits a form Documentation

Node

Methods

appendChild()object.appendChild() Documentation

Fetch API

Example

fetchconst p1 = fetch('http://…')
  .then(resp => resp.json())
  .then(data => data)
  .catch(err => console.log(err)) Documentation