← Reference

Building blocks: cheat sheet

The DOM and the browser console · In any playground, open Reference to copy these.

read a box

Read what someone typed into the box with id="name".

const name = document.querySelector('#name').value;

function in setup

A function the page can run (return it from setup). In the script, a ref's value is in .value.

function addPoint() {
  score.value++;
}